Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Send Email  with VBScript

Posted on 1998-12-30
3
Medium Priority
?
528 Views
Last Modified: 2008-02-20
I need to send a email with VBScript on a system with NT 4.0, IIServer 4.0 and Exchange 5.5 and ASPMail.

Email is into Intraweb, users of Exchange 5.5.

What's Code i need to execute?.
0
Comment
Question by:javi2
3 Comments
 
LVL 3

Expert Comment

by:vmano
ID: 1453326
here is an MSDN article Q176914. URL is
http://support.microsoft.com/support/kb/articles/q176/9/14.asp?FR=0 

let me know if that helps
vmano
0
 
LVL 1

Accepted Solution

by:
wdavidsmith earned 150 total points
ID: 1453327
Here's the simple, easy solution I recently employed...

1.) Include the MAPI32 ActiveX control tags in your page. Both tags reference the same OCX. The message control AND the session control are both embedded into this OCX file. Make sure the codebase path is correct for your site. Also make sure you have the OCX file in the referenced folder.

NOTE:The MSMAPI32.ocx control is a licensed control. You'll need to include an LPK tag to license the control. The LPK file can be created with the LPK License Tool.

<OBJECT codebase="Controls/MSMAPI32.ocx"
 ID="ctlMessage" WIDTH=39 HEIGHT=39
 CLASSID="CLSID:20C62CAB-15DA-101B-B9A8-444553540000">
    <PARAM NAME="_ExtentX" VALUE="1005">
    <PARAM NAME="_ExtentY" VALUE="1005">
    <PARAM NAME="_Version" VALUE="327680">
    <PARAM NAME="AddressEditFieldCount" VALUE="1">
    <PARAM NAME="AddressModifiable" VALUE="0">
    <PARAM NAME="AddressResolveUI" VALUE="0">
    <PARAM NAME="FetchSorted" VALUE="0">
    <PARAM NAME="FetchUnreadOnly" VALUE="0">
</OBJECT>

<OBJECT codebase="Controls/MSMAPI32.ocx"
 ID="ctlSession" WIDTH=39 HEIGHT=39
 CLASSID="CLSID:20C62CA0-15DA-101B-B9A8-444553540000">
    <PARAM NAME="_ExtentX" VALUE="1005">
    <PARAM NAME="_ExtentY" VALUE="1005">
    <PARAM NAME="_Version" VALUE="327680">
    <PARAM NAME="DownloadMail" VALUE="0">
    <PARAM NAME="LogonUI" VALUE="0">
    <PARAM NAME="NewSession" VALUE="0">
</OBJECT>

2.) Copy and paste the following into your page
<SCRIPT LANGUAGE="VBScript">
Sub SendMessage(strAddress, strSubject, strMessage)

   ' If the address, subject and message variables are in place
   If strAddress = "" Or strSubject = "" Or strMessage = "" Then
      ' Either the address, subject and/or message variables were empty
      MsgBox "Error Constructing Email Message"
      Exit Sub
   End If

   ' If a messaging system session does NOT exist
   If ((ctlMessage.SessionID = 0) Or IsNull(ctlMessage.SessionID)) Then
      ' Log the user on to the messaging system
      ctlSession.SignOn
      ' Get the messaging system session ID
      ctlMessage.SessionID = ctlSession.SessionID
   End If

   ' Compose the email from the variables
   ctlMessage.Compose
   ctlMessage.AddressResolveUI = 0
   ctlMessage.RecipAddress = varAddress
   ctlMessage.MsgSubject = varSubject
   ctlMessage.MsgNoteText = varMessage
   ctlMessage.ResolveName
     
   ' Send the email without user interaction
   ctlMessage.Send 0
     
   ' If an error was encountered
   If Err.Number > 0 Then
      ' Display an error message (email application probably not open)
      MsgBox "ERROR: " & CStr(Err.Number) & Chr(13) & _
                     "Unable to Send Email" & Chr(13) & Chr(13) & _
                     "Make sure you Email Program" & Chr(13) & _
                     "is Open and working correctly"
      ' Clear the error
      Err.Clear
      Exit Sub
   Else
      ' Display a success message
      MsgBox "Email Sent"
   End If

End Sub
</SCRIPT>

NOTE: The users will need to have their email application (i.e. Exchange) open for the control to access it.

3.) Call the SendMessage sub with the email address, subject, and message strings. For example:
SendMessage("joe@hishouse.net", "Kewl Email!", "Hey Joe...")

I have literally hunderds of users who use this on a daily basis and it works great. I hope this helps...


0
 

Author Comment

by:javi2
ID: 1453328
Very Thanxs, i will try it soon.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question