blasted Posted December 27, 2011 Posted December 27, 2011 Hi all, Please help me with my scripting problem. Here is the situation: I have to send a message from specific email address from VBScript. I've got Exchange server 2003 and MS Outlook 2007 as an appplication if this matters. My code is listed below. It works perfect but I sending out message only from my profile. How to use ns.Logon correctly to use another account or should I use something else instead of it? Dim ToAddress Dim MessageSubject Dim MessageBody Dim MessageAttachment Dim ol, ns, newMail ToAddress = "[email protected]" MessageSubject = "subject text" MessageBody = "body" MessageAttachment = "path_to_attachment" Set ol = WScript.CreateObject("Outlook.Application") Set ns = ol.getNamespace("MAPI") ns.logon "", "", true, false Set newMail = ol.CreateItem(olMailItem) newMail.Subject = MessageSubject newMail.HTMLBody = MessageBody & vbCrLf Set myRecipient = ns.CreateRecipient(ToAddress) myRecipient.Resolve If Not myRecipient.Resolved Then MsgBox "unknown recipient" Else newMail.Recipients.Add(myRecipient) newMail.Attachments.Add(MessageAttachment).Displayname = "name" newMail.Recipients.Add(CCAddress) newMail.Send End If Set ol = Nothing
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now