07-30-2012, 04:02 PM
'Email generation VB Script snipet.
'Pre requisite: MS Outlook apllication up running on the desktop
'Pre requisite: MS Outlook apllication up running on the desktop
Code:
Dim ToAddress
Dim Subject
Dim Body
Dim Attachment
Dim oUtlookApp, nAmeSpace, newMail
'SystemUtil.Run "C:\Program Files\Microsoft Office\Office11\OUTLOOK.EXE" 'This line should be enabled if the Outlook on the desktop is not running
SystemUtil.Run "C:\Program Files\Outlook Express\msimn.exe"
ToAddress = "xyz@gmail.com" ' Message recipient Address
Set oUtlookApp = CreateObject("Outlook.Application")
Set nAmeSpace = oUtlookApp.GetNamespace("MAPI")
Set newMail = oUtlookApp.CreateItem(0)
Subject = "This is a test mail" 'Message Subject you can update
Body = "This the message for testing. " 'Message body you can update
newMail.Subject = Subject
newMail.Body = Body & vbCrLf
newMail.Recipients.Add(ToAddress)
newMail.Attachments.Add("D:\Automation\report\login.html") 'You can update attachment file name
newMail.Send
Set nAmeSpace = Nothing
Set oUtlookApp = Nothing
'end of the email generation code===================================================================