Solved

Send Email  with VBScript

Posted on 1998-12-30
3
517 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 50 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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
Course of the Month3 days, 21 hours left to enroll

630 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