Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML in body of an Email

Status
Not open for further replies.

cdms

Programmer
Feb 12, 2002
27
0
0
GB
I'm having trouble assigning a pre-defined .htm file to the body of a outlook email.

Can anyone give me a quick + easy answer?

Thanks
 
What trouble are you having? An what method of Automation are you using? Outlook, MAPI, CDO ? Can you post some code?
 
Here is an example using CDO.DLL
Code:
oMSG = createobject("CDO.Message")
oMSG.To = "jordanbaumgardner@earthlink.net"
oMSG.From = "jordanbaumgardner@earthlink.net"
oMSG.Subject = "Hello Email"
oMSG.HTMLBody = [< b >< P >< FONT COLOR=&quot;#CC0000&quot; >Hello In Color< /FONT >< /b >]
oMSG.Send()

 
This is the sort of code I am using. I may be going down completly the wrong road. Perhaps you could help.

OAPP = CREATEOBJECT(&quot;Outlook.Application&quot;)
OMAIL = OAPP.CREATEITEM(0)
OMAIL.TO = &quot;email address&quot;
OMAIL.SUBJECT = &quot;Subject&quot;
OMAIL.BODY = &quot;this is where I want my .htm file&quot;
OMAIL.Send()
RELEASE OAPP
RELEASE OMAIL

Thanks a lot

Chris
 
Are you trying to attach an HTML file or write HTML code?
If you tryng to attach you would use the attachement Action, like this:
Code:
#DEFINE MAILITEM 0
#DEFINE IMPORTANCELOW 0
#DEFINE IMPORTANCENORMAL 1
#DEFINE IMPORTANCEHIGH 2

oOutLookObject = CreateObject(&quot;Outlook.Application&quot;)
oEmailItem = oOutLookObject.CreateItem(MAILITEM)

WITH oEmailItem
   .Recipients.Add(&quot;moe@3stooges.com&quot;)
   .Subject = &quot;Automation sample&quot;
   .Importance = IMPORTANCENORMAL
   .Body = &quot;This is easy!&quot;
   .Attachments.Add(&quot;c:\mydir\sample.htm&quot;) 
   .Send
ENDWITH

RELEASE oEmailItem
RELEASE oOutLookObject

If you trying to write HTML change the body line above to this
[code]
   .Body = [< b >< P >< FONT COLOR=&quot;#CC0000&quot; >Hello In Color< /FONT >< /b >]
 
I have the html code in the .htm file but when I tryed your example it literally put the html string in the body ie. it didn't convert it (outlook is set to send HTML messages). Any ideas?

Thanks for the help

Chris
 
I did a test using CDO.dll and I was able to send an HTML message to myself using this code:
Code:
oMSG = createobject(&quot;CDO.Message&quot;)
oMSG.To = &quot;mike.gagnon@slpcanada.com&quot;
oMSG.From = &quot;mike.gagnon@slpcanada.com&quot;
oMSG.Subject = &quot;Hello Email&quot;
oMSG.HTMLBody = &quot;<html><body><p>Please plan to present your status for the following projects...</p></body></html>&quot;
oMSG.Send()

I think originally I forget the HTML tags and the quatation marks.
 
Thanks again mgagnon

Unfortunitly I am dealing with about 12 pages of html from a different file that would be sent to me regularly. I think it would be far to time consuming to convert the code every time.

I have an outlook.h file that I include in the form.

It has lots of useful commands and I know that one of them would sort this problem out.

Unfortunitly I don't know the syntax to be able to call these specific commands from vfp6.

Any advise would be appreciated

Thanks

Chris
happy.gif
 
Thanks again mgagnon

Unfortunitly I am dealing with about 12 pages of html from a different file that would be sent to me regularly. I think it would be far to time consuming to convert the code every time.

I have an outlook.h file that I include in the form.

It has lots of useful commands and I know that one of them would sort this problem out.

Unfortunitly I don't know the syntax to be able to call these specific commands from vfp6.

Any advise would be appreciated

Thanks

Chris
 
HI Chris,

OAPP = CREATEOBJECT(&quot;Outlook.Application&quot;)
OMAIL = OAPP.CREATEITEM(0)
OMAIL.TO = &quot;email address&quot;
OMAIL.SUBJECT = &quot;Subject&quot;
[COLOR=/blue]
** OMAIL.BODY = &quot;this is where I want my .htm file&quot;
OMAIL.ATTACHMENTS.ADD(myHTMLFile)
** or **
OMAIL.ATTACHMENTS.ADD(GETFILE())
[COLOR=/]
OMAIL.Send()
RELEASE OAPP
RELEASE OMAIL

Hope his helps you :) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top