I've been working on a simple enough email procedure to send emails with outlook (see code below)
Now, i've actually gotten it to work. It was the first thing i got to work. Then i worked on the CCs and the attachments, which now also works fine. But the emails are not sending as HTML. it sends the code as straight text.
Wait, that's not quite right. It sends as straight text because i'm using .Body. But that's because now, when i use .HTMLBody, no text will send. Its just an empty email, with subject, attachments, cc, and a recipient.
I simply don't get it. Naturally, i've done something. But, if i use .HTMLBody, the email will have absolutely no text. Is there a step i'm missing?
according to faq184-1700, everything looks fine. faq184-766 does not mention sending HTML at all.
I tried CDO.Message examples, and they seem to send (ie no error occurs...) but i've never received a message sent with it. Besides, i'm supposed to use outlook. not my choice, but the purpose is to have our software work with MS Office as much as possible.
Thanks
PROCEDURE send_email
PARAMETERS cEmail, cSubject, cText, cCC, cCCi, cAttachments
LOCAL oOutlook, oNameSpace, oMessage, cHTML
#DEFINE olMailItem 0
oOutlook = CREATEOBJECT( "Outlook.Application" )
oNameSpace = oOutlook.GetNameSpace( "MAPI" )
oMessage = oOutlook.CreateItem( olMailItem )
WITH oMessage
.Subject = cSubject
cHTML = STRTRAN(cText, CHR(13) + CHR(10), "<BR>"
**_body = eml_head.text + cText + eml_foot.text
.Body = cHTML && <--sends html as straight text
**.HTMLbody = _body && <-- sends nothing
** (..and not because the line concerning _body above is commented!!)
.Recipients.Add( ALLTRIM(cEmail) )
lResolved = .Recipients.ResolveAll()
.CC = cCC
.BCC = cCCi
.Attachments.Add( ALLTRIM(cAttachments) )
.Save()
.Send()
ENDWITH
oNamespace.Logoff
RETURN
Now, i've actually gotten it to work. It was the first thing i got to work. Then i worked on the CCs and the attachments, which now also works fine. But the emails are not sending as HTML. it sends the code as straight text.
Wait, that's not quite right. It sends as straight text because i'm using .Body. But that's because now, when i use .HTMLBody, no text will send. Its just an empty email, with subject, attachments, cc, and a recipient.
I simply don't get it. Naturally, i've done something. But, if i use .HTMLBody, the email will have absolutely no text. Is there a step i'm missing?
according to faq184-1700, everything looks fine. faq184-766 does not mention sending HTML at all.
I tried CDO.Message examples, and they seem to send (ie no error occurs...) but i've never received a message sent with it. Besides, i'm supposed to use outlook. not my choice, but the purpose is to have our software work with MS Office as much as possible.
Thanks
PROCEDURE send_email
PARAMETERS cEmail, cSubject, cText, cCC, cCCi, cAttachments
LOCAL oOutlook, oNameSpace, oMessage, cHTML
#DEFINE olMailItem 0
oOutlook = CREATEOBJECT( "Outlook.Application" )
oNameSpace = oOutlook.GetNameSpace( "MAPI" )
oMessage = oOutlook.CreateItem( olMailItem )
WITH oMessage
.Subject = cSubject
cHTML = STRTRAN(cText, CHR(13) + CHR(10), "<BR>"
**_body = eml_head.text + cText + eml_foot.text
.Body = cHTML && <--sends html as straight text
**.HTMLbody = _body && <-- sends nothing
** (..and not because the line concerning _body above is commented!!)
.Recipients.Add( ALLTRIM(cEmail) )
lResolved = .Recipients.ResolveAll()
.CC = cCC
.BCC = cCCi
.Attachments.Add( ALLTRIM(cAttachments) )
.Save()
.Send()
ENDWITH
oNamespace.Logoff
RETURN