*- Parameters.:
*-
*- cRecipient : Receipient's E-mail
*- cCCList : Copy to
*- cSubject : E-mail Subject
*- cMessage : E-mail Message
*- cAttachment : E-mail Attachement
*-
*- Objects....:
*-
*------------------------------------------------------------------------------
PARAMETER cRecipient,cCCList,cSubject,cMessage,cAttachment
IF TYPE('oOutlook')=='O'
RELEASE oOutlook
ENDIF
LOCAL lcError, llOutlookError
lcError = ON("ERROR")
llOutlookError = .F.
ON ERROR llOutlookError = .T.
oOutlook=CREATEOBJECT("Outlook.application")
oSpace=oOutlook.Getnamespace("MAPI")
oMsg=oSpace.GetDefaultFolder(6)
oNew=oMsg.Items.ADD()
ON ERROR &lcError.
IF TYPE('oOutlook') <> "O" OR ;
TYPE('oMsg') <> "O" OR ;
TYPE('oNew') <> "O"
RETURN .F.
ENDIF
cString=cRecipient
lcstring=cString
DO WHILE .T.
token=''
N=AT(';',lcstring)
IF N=0
token=lcstring
EXIT
ELSE
token=SUBSTR(lcstring,1,N-1)
lcstring=SUBSTR(lcstring,N+1)
ENDIF
oNew.Recipients.ADD(token)
ENDDO
IF !EMPTY(ALLTRIM(token))
oNew.Recipients.ADD(token)
ENDIF
*----------------------------------
*- Send a copy to the author of the e-mail
IF NOT EMPTY(ALLTRIM(cCCList))
*- JCZA
*- 01/03/2003
cString=cCCList
lcstring=cString
DO WHILE .T.
token=''
N=AT(';',lcstring)
IF N=0
token=lcstring
EXIT
ELSE
token=SUBSTR(lcstring,1,N-1)
lcstring=SUBSTR(lcstring,N+1)
ENDIF
orecip=oNew.Recipients.ADD(token)
orecip.TYPE=2 && copy cc
ENDDO
IF !EMPTY(ALLTRIM(token))
orecip=oNew.Recipients.ADD(token)
orecip.TYPE=2 && copy cc
ENDIF
ENDIF
oNew.Subject=cSubject
oNew.Body=cMessage
IF !EMPTY(ALLTRIM(cAttachname))
oNew.Attachments.ADD(cAttachment,1,1,cAttachname)
ENDIF
RETURN oNew.SEND()
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only