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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDO email

Status
Not open for further replies.

edgardg

IS-IT--Management
May 9, 2001
51
AR
I'm trying to send emails with CDO but I can't find a way to embedded a html page I created.
I don't want to attach it. It has to display the html page.
I'm using a sample I found on this site like this:

how can I do that?
thanks for you help

Code:
cdoSendUsingPickup = 1
cdoSendUsingPort = 2 
cdoAnonymous = 0
cdoBasic = 1 &&' clear text
cdoNTLM = 2 && 'NTLM
cdoDSNDefault = 0 &&'None
cdoDSNNever = 1 &&'None
cdoDSNFailure = 2 &&'Failure
cdoDSNSuccess = 4 &&'Success
cdoDSNDelay = 8 &&'Delay
cdoDSNSuccessFailOrDelay = 14 

objMsg = CREATEOBJECT("CDO.Message")
objConf = CREATEOBJECT("CDO.Configuration")


objFlds = objConf.FIELDS
WITH objFlds
	.ITEM("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = cdoSendUsingPort
	.ITEM("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "x.x.x.x"
	.ITEM("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")[/URL] = cdoBasic
	.ITEM("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername")[/URL] = "username"
	.ITEM("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")[/URL] = "ed"
	.UPDATE
ENDWITH

strBody = "This is a sample message."
strBody = strBody + "It was sent using CDO."

WITH objMsg
	.Configuration = objConf
	.TO = "myemail.com"
	.FROM = "sender.com"
	.Subject = "This is a CDO test message"
	.TextBody = strBody
	*.Addattachment "c:\temp\test.zip"
	.FIELDS("urn:schemas:mailheader:disposition-notification-to") = "myemail.com"
	.FIELDS("urn:schemas:mailheader:return-receipt-to") = "other.com"
	.DSNOptions = cdoDSNSuccessFailOrDelay
	.FIELDS.UPDATE
	.SEND
ENDWITH
 
I'm aware of HTMLbody, but that wont let me "embedd" the html file I have in my hard drive. (unless I'm missing something)
the html page has pic and all that. I don't want a link either.
The way I was doing it before was opening the html page on the browser and then "send page as html"
I want to do the samething from foxpro using CDO

Thanks
 
To store an HTML file in HTMLBody, you could to this:

objMsg.HTMLbody = FILETOSTR("c:\myfolder\myfile.htm")

However, I agree that this won't embed the pictures. To do that, you would have to save the web page as an MHT file. To do that in IE, select File / Save As, then choose "Web archive single file" from the "Save as Type" combo.

Once you've done that, you can apply the FILETOSTR() technique mentioned above. The pictures will be transmitted in the body of the email.

If you want to automate the saving of the page to MHT, that would be possible by accessing IE through COM Automation, but that goes beyond your original question.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
You need to create a MHTML document using CDO. Of course this assume you already have an existing HTML page.

Code:
Local  oCDO 
v_mhtml = Sys(2015)+".mht"
oCdo = Createobject("CDO.Message")
oCdo.CreateMHTMLBody("[URL unfurl="true"]http://www.atoutfox.org")[/URL]
ocdo.To = "mg@mcrgsoftware.com"
ocdo.send()


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
MikeLewis,

Sorry Mike I posted at the same time as you I believe, but CDO has its own function to create MHTML documents.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
that's a great solution Mike. Thanks a lot.

Now, I was just able to acheive what I wanted with:
Code:
.CreateMHTMLBody ("file://C:/Temp/myhtmlPage.html")

again, thanks so much for your help
 
Edgardg

Yes the syntax for local files is lillte tricky, but yours looks right. One thing to be aware, as I found out, you cannot use spaces in either the drirectory name of the filename.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Mike,

Sorry Mike I posted at the same time as you I believe, but CDO has its own function to create MHTML documents.

No apology necessary. I hadn't realised you could create MHTML in that way. Worth remembering.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thank you very much mgagnon.
I keep that in mind. I'll also try your suggestion.
Now I wonder what would be best way to send these htlm files.
I have a hard time displaying similarly on different browser/email clients.

Looks good on Oulook, Yahoo but not what I want in gmail, Hotmail. Even worst on a Mac
Any suggestions on that?

 
edgardg

Looks good on Oulook, Yahoo but not what I want in gmail, Hotmail. Even worst on a Mac

The picture gets scrambled somewhat. I have research that a while back, but have not found any suitable solution. I noticed that problem lies in the whay the page the HTML page is constructed. Mostly related to the postions of objects in the page (relative positionning vs fixed positionning). Where Outlook would interpret the page differently than Hotmail.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Most of my problems are with tables. I cannot find a way to get them in the right place or keep the border color.
since using some inline css I thought that would be the problem, but even plain html would not help.

oh well.
thanks Mike

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top