Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Outlook automation: send cc: and display dialog
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00299892
Message ID:
00299910
Views:
21
>Hi,
>
>I am doing my 1st automation with outlook. I am using an example for "foxforum" (i Think) and it works real well. However, I can't find the property for doing a cc: recipient. I would also like to bring up the outlook dialog instead of just the send.
>
>Any help would be appreciated.
>
>Kevin
>
>*******************************************
>oOutLookObject = CreateObject("Outlook.Application")
>oEmailItem = oOutLookObject.CreateItem(MAILITEM)
>WITH oEmailItem
> .To = m.sendto && ; separated list.
> *.ccTo =m.ccTo && also tried .cc
> .Subject = m.jcsubject
> .Importance = IMPORTANCEMORMAL
> .Body = m.jcmessage
> IF NOT EMPTY(lcattach1)
> .Attachments.Add(lcattach1)
> ENDIF
> .Send && would like to bring dialog up instead of blind send
>ENDWITH
>
>Release oEmailItem
>Release oOutLookObject

Here is some code from where I perform my mail process, CC is in there

*MailRecipientType
#Define olOriginator 0
#Define olTo 1
#Define olCC 2
#Define olBCC 3

LOCAL onamespace, ooutlook, omailitem1
LOCAL mcsubject, mcto, mccc, mcfrom, mcfile

ooutlook = CreateObject("Outlook.Application")
onamespace = ooutlook.GetNameSpace("MAPI")

LOCATE
SCAN FOR wasmailed = .F.
* Now lets gather the data together into a simple form for Emailing
*
mcsubject = ALLTRIM(subject)
mcto = ALLTRIM(towhom)
IF NOT EMPTY(ccwhom)
mccc = ALLTRIM(ccwhom)
ENDIF
mcfrom = ALLTRIM(fromwhom)

* Create a new mail message
omailItem = ooutlook.CreateItem(olMailItem)

* Set the properties of the mail message
WITH omailItem
* Add a recipient (Note: If recipient is
* in the address book just use the display name,
* otherwise include the complete address)
WITH .Recipients.Add(mcto)
.Type = olTo
ENDWITH
IF NOT EMPTY(ccwhom)
WITH .Recipients.Add(mccc)
.Type = olCC
ENDWITH
ENDIF
IF NOT EMPTY(attachment)
mcfile = ALLTRIM(attachment)
WITH .Attachments.Add(mcfile)
* For some reason the type appears to
* be read only, but the mai goes through OK
* .Type = olByValue
IF NOT EMPTY(attachdesc)
.DisplayName = attachdesc
ELSE
.DisplayName = mcsubject
ENDIF
ENDWITH
ENDIF
* Since we have no way now to indicated who this
* mail came from, we will put the originator's name in the body
*
IF NOT EMPTY(mailbody)
.Body = 'Message originated from: '+mcfrom+CHR(13)+CHR(13)+mailbody
ELSE
.Body = 'Message originated from: '+mcfrom
ENDIF
.subject = mcsubject
.Importance = olImportanceNormal
* Send it!
.Send
ENDWITH
* The time out is here to ensure that the file does not get deleted to
* soon
WAIT TIMEOUT 5
REPLACE wasmailed WITH .T.
REPLACE dateout WITH DATE()
REPLACE timeout WITH TIME()
IF deletefile
* For some reason I could not erase the attachment
* unless I put it into a variable first
prfile = ALLTRIM(attachment)
ERASE &prfile
ENDIF
ENDSCAN
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform