WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE and Outlook
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

OLE Outlook Example

Keywords:   ole outlook send mail  unicode

Question:

Per the response from your developers......I already know that WinBatch does not have arrays and I can get around that using lists. I just need help to determine how to use WinBatch to send an Outlook mail message with OLE.....just the basics. So far I what I have opens an OLE channel and displays the mail item, but I can't get it to add the Recipient, Subject, Body and attachment or send the message.

We have many programs that are using DDE which we can no longer use. We need to convert them all to OLE.

Any additional would be greatly appreciated! Thanks

Answer:

The following is a script demonstrating how to use OLE with Outlook.
; modify these strings to reference the recipient email and path to file attachment
recip="name@windowware.com"
AttachmentPath="C:\Temp\testfile.txt"


; Create the Outlook session.
objOutlook = ObjectCreate("Outlook.Application")

; Create the message.
objOutlookMsg = objOutlook.CreateItem(0)

; Display to user (the following line can be removed if you do not want any interface)
objOutlookMsg.Display

; add Recipient
objOutlookRecip=objOutlookMsg.Recipients
objOutlookRecip.Add(Recip)


; Set the Subject, Body,
objOutlookMsg.Subject = "This is an Automation test with Microsoft Outlook"
objOutlookMsg.Body = StrCat("This is the body of the message.",@CRLF)

; Add attachments to the message.
objOutlookAttach = objOutlookMsg.Attachments
objOutlookAttach.Add(AttachmentPath)


objOutlookMsg.Send

objOutlook = 0
Exit

Article ID:   W13678
Filename:   Outlook Sendmail OLE Example.txt
File Created: 2011:09:20:10:24:20
Last Updated: 2011:09:20:10:24:20