Code Script .co.uk

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Create Email In Mailbox
 

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.
 
   Actions
  Go Back
  Bookmark
  Print Page


   Menu
 
- Links
- Reference
- Script Editors
- Tutorials
- Vbscript
     - Active Directory
     - Exchange
     - Files And Folders
     - General
     - Ms Office
          - Create Email In Mailbox
          - Create Email With Past Date
          - Create Mailbox Folders In Pst File
          - Find Acronyms In Word Document
          - Outlook Autocomplete Import
          - Read Data From Spreadsheet
          - Read Word Document
          - Word Edit User Properties
          - Word File Save Location
          - Word Hide Toolbar
          - Word Template Location
     - Operating System
     - Processes And Services
     - Text Processing
     - User Interaction
     - Web Servers