Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


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 = ObjectOpen("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
        
ObjectClose(objOutlook)
exit


Article ID:   W13678
Filename:   Outlook Sendmail OLE Example.txt