Search
Enter Keywords:
Home
Send an Email Via Outlook from VB or VBScript PDF Print E-mail
User Rating: / 1
PoorBest 
Written by Michael Salsbury   
Wednesday, 15 June 2005

The VBScript code below will send an email message through Microsoft Outlook (the Exchange Server version, it probably won't work with Outlook Express) when you call it from your script.  Using this subroutine you can customize the subject and content of the mail message as well as its recipients.

To use it, the syntax is:

  mailThisMessage toAddress, bccList, ccList, subjectLine, theMessage

where:

toAddress is the email address you want to send the message to (use ";" for multiple addresses)

bccList is the list of email addresses you want to "bcc" the mail message to via Outlook

ccList is the list of email addresses you want to copy the mail message to via Outlook

subjectLine is the subject line of the message you're sending via Outlook

theMessage is a text field containing the actual message you want to send, in HTML format, via Microsoft Outlook mail

As with all my scripts and code, this is provided without warranty or support.  Use at your own risk.

Public Sub mailThisMessage(toAddress As String, bccList As String, ccList As String, subjectLine As String, theMessage As String)
    Dim olNameSpace As Outlook.NameSpace
    Set olNameSpace = Outlook.GetNamespace("MAPI")
    Dim fldInbox As Outlook.MAPIFolder
    Set fldInbox = olNameSpace.GetDefaultFolder(olFolderInbox)
    Set themsg = fldInbox.Application.CreateItem(olMailItem)
    themsg.To = toAddress
    themsg.BCC = bccList
    themsg.CC = ccList
    themsg.Subject = subjectLine
    themsg.HTMLBody = theMessage
    themsg.Send
    olNameSpace.Logoff
    Set olNameSpace = Nothing
    Set themsg = Nothing
    Set fldInbox = Nothing
End Sub


Related Blogs:

Related Links:

Last Updated ( Saturday, 25 March 2006 )
< Previous

Main Menu
Home
Blog
Photos
Links
Search
Site Index
Feedback
Administrator
Featured Links
BlogInspiration
SpamToons
Shawn Prince's Blog
Jack Ludwig's Blog
Mike Cramer's Site
Fark
Slashdot
Woot!
Cigar Envy
John Kricfalusi's Blog
CigarBlog 101
Cigars 101 Forum
Sponsored Links


View Site Stats