Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Send Email  with VBScript

Posted on 1998-12-30
3
Medium Priority
?
523 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 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…
Suggested Courses

670 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