keepingbusy
Programmer
The below code was found on one of our Tek-Tip forum users website (Craig Boyd).
I have tried this using Fox 6 and Outlook 2007.
The only problem is that the HTML code is showing in the body of the email when it is received by the recipient. Otherwise it is working fine.
In some previous code we had, there was a line that looked like:
We tried putting the <HTML> tags in but that doesn't work either.
We have had to change the old procedure due to circumstances beyond our control.
Can anyone shed any light on what is missing / needs amending to make it work?
Thank you
Lee
I have tried this using Fox 6 and Outlook 2007.
The only problem is that the HTML code is showing in the body of the email when it is received by the recipient. Otherwise it is working fine.
Code:
* THE FOLLOWING ARE NORMALLY FROM A TABLE
STORE "myemail@soewhere.com" TO memail
STORE "Your order details: " TO mcontent
STORE "657643219534" TO mtransact
#DEFINE olImportanceLow 0
#DEFINE olImportanceNormal 1
#DEFINE olImportanceHigh 2
LOCAL lcTo, lcSubject, lcBody, lcCC, lcBCC, llHTMLFormat, llOpenEmail, lcErrReturn
lcTo = ALLTRIM(memail)
lcSubject = "Information: "+ALLTRIM(mcontent)+" "+ ;
ALLTRIM(mtransact)
*!* Sending the body in HTML format
llHTMLFormat = .T.
[b]* THIS WORKS[/b]
lcBody = "Dear customer: "+ALLTRIM(mcontent)+" "+ALLTRIM(mtransact)
[b]* THIS DOESN'T AND SHOWS THE HTML CODING[/b]
lcBody = "<a href='[URL unfurl="true"]http://www.websitename.com/somepages/index.htm'>"[/URL] + ;
"Inforamtion Page" + ;
"</a>"
*!* to automatically send email set llOpenEmail to .F.
llOpenEmail = .T. && Whether email is opened in Outlook or not
SendViaOutlook(@lcErrReturn, lcTo, lcSubject, lcBody, llHTMLFormat, olImportanceHigh, llOpenEmail)
IF EMPTY(lcErrReturn)
MESSAGEBOX("'" + lcSubject + "'" + IIF(llOpenEmail, " opened ", " sent ") + "successfullly.", 64, "Send email via Outlook")
ELSE
MESSAGEBOX("'" + lcSubject + "' failed to be sent. Reason:" + CHR(13) + lcErrReturn, 64, "Send email via Outlook")
ENDIF
***********************************************************
PROCEDURE SendViaOutlook(tcReturn, tcTo, tcSubject, tcBody, taFiles, ;
tcCC, tcBCC, tlHTMLFormat, tnImportance, tlOpenEmail)
***********************************************************
LOCAL loOutlook, loItem, lnCountAttachments, loMapi
loOutlook = CREATEOBJECT("outlook.application")
loMapi = loOutLook.GetNameSpace("MAPI")
loMapi.Logon()
loItem = loOutlook.CreateItem(0)
WITH loItem
.Subject = tcSubject
.TO = tcTo
IF tlHTMLFormat
.HTMLBody = tcBody
ELSE
.Body = tcBody
ENDIF
IF TYPE("tnImportance") != "N"
tnImportance = 1 && normal importance
ENDIF
.Importance = tnImportance
IF tlOpenEmail
.DISPLAY()
ELSE
.SEND()
ENDIF
ENDWITH
RELEASE oOutlook, oItem
STORE .NULL. TO oOutlook, oItem
In some previous code we had, there was a line that looked like:
Code:
.HtmlBody = "<HTML><BODY> ;
<br><br>Received by us on: <B>"+cdow(mdaterec)+" "+dmy(mdaterec)+"</B> ;
edited....
<br><br>"+TRIM(memailnot)+" ;
</BODY> ;
</HTML>"
We tried putting the <HTML> tags in but that doesn't work either.
We have had to change the old procedure due to circumstances beyond our control.
Can anyone shed any light on what is missing / needs amending to make it work?
Thank you
Lee