Vbscript / Ms Office / Create Email In Mailbox
Create a bulk of test email in Exchange mailbox using Outlook. Specify number of messages to create and a file attachment.
Set objFSO = CreateObject("Scripting.FileSystemObject") amount = InputBox("Enter No. of mail messages to generate","No. of mail messages",10) attach = InputBox("Enter the full path of the attachment","Attachment","c:attach.doc") willAttach = 1 While objFSO.FileExists(attach) = 0 attach = InputBox("Enter the full path of the attachment","Attachment","c:attach.doc") If attach = "" Then willAttach = 0 WScript.Quit End If Wend Set oOutlook = CreateObject("Outlook.Application") Set oNameSpace = oOutlook.GetNamespace("MAPI") For i=0 To amount Set newMail = oOutlook.CreateItem(olMailItem) newMail.Subject = "TestMail " & i newMail.Body = "This is a test mail message generated by VBScript" newMail.To = "SomeUser" Set atts = newMail.Attachments If willAttach Then atts.Add(attach) End If newMail.Save Set newMail = Nothing Set atts = Nothing Next WScript.Echo "Complete"
Please note that a disclaimer applies to any code on this page.
|