Jump to content

blasted

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by blasted

  1. 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
×
×
  • Create New...