sentme_mail
04-10-2003, 09:30 AM
hi,
how can i automate sending of mails using outlook client? thanks
strMailRecipient = "Jama@SomeDomain.com"
strMailSubject = "Mail From Script"
strMailBody = "This is coming from a script"
strMailBody = strMailBody & GetScriptFile
Const olMailItem = 0
Const olCC = 2
SendMail strMailRecipient, strMailSubject, strMailBody
Sub SendMail (recipients, subject, body)
Dim Outlook, Email, NameSpace
Set Outlook = Wscript.CreateObject("Outlook.Application")
Set Email = Outlook.CreateItem(olMailItem)
Set NameSpace = Outlook.GetNameSpace("MAPI")
Email.Subject = subject
Email.Body = body
Dim recipient
If VarType(recipients) <> 8 Then
For Each recipient In recipients
Email.Recipients.Add recipient
Next
Else
Email.Recipients.Add recipients
End If
Email.Send
NameSpace.Logoff
Set NameSpace = Nothing
Set Email = Nothing
Set Outlook = Nothing
End Sub
'================================================= ===================
' Function to attach script code to end of email message, delete if
' you wish. If you delete this function, also delete the line that
' called it, which is;
' strMailBody = strMailBody & GetScriptFile
Function GetScriptFile()
w = WScript.ScriptFullName
Set f = CreateObject("Scripting.FileSystemObject")
Set a = f.OpenTextFile(w, 1)
GetScriptFile = String(10, vbNewline) & a.ReadAll
a.Close
End Function
'================================================= ===================
Jama
Powered by vBulletin™ Version 4.1.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.