WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: domvalle@comcast.net on March 29, 2018, 06:37:52 AM

Title: Help to add CC w/Outlook
Post by: domvalle@comcast.net on March 29, 2018, 06:37:52 AM
Hi, need help with CC recipient in Outlook.
unable to set recipient.type to olCC.

; 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("someone@somewhere.net")
;______________________________________________________________________________
;                         ? HOW TO  CC ?
;Recipients.Add('joesmoe@yahoo.com').Type := 2; // olCC     VB example
objOutlookRecip.Add('joesmoe@yahoo.com').Type=2             * Does not work in WB? *
;______________________________________________________________________________
; Set the Subject, Body,
objOutlookMsg.Subject = "subject"
objOutlookMsg.Body = "objOutlookMsg.Body"
exit
Title: Re: Help to add CC w/Outlook
Post by: td on March 29, 2018, 07:39:12 AM
Assuming that you mean that setting the recipient type does not seem to have any effect and that you are getting some kind of error,  you need to the same thing for both VB and WinBatch.  That thing being you need to call the ResolveAll method
Code (winbatch) Select
objOutlookRecip.ResolveAll() on the recipients collection after you are done adding recipients. 
Title: Re: Help to add CC w/Outlook
Post by: domvalle@comcast.net on April 09, 2018, 05:47:29 PM
thanks,
did that plus this:
objOutlookRecip.Add('someone@somewhere.com').Type = 2; // olCC
this put the recip on the cc line.
-domvalle