Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Embed images in emails
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01237212
Message ID:
01237595
Views:
20
Hi Mike,

>Wouldn't this "CdoReferenceTypeName" constant cause an error in VFP?

For the sample I posted, that constant worked fine, but the image embedding does not work nice with all email programs.

I had to make some other tweaks, and it seems to be working as desired. I'll make some new tests, and hope to pos the final version here soon.



>
>>Thanks Sergey !
>>
>>I've just found the solution in this russian forum, using the "AddRelatedBodyPart" function:
>>http://www.sql.ru/forum/actualthread.aspx?tid=79485
>>
>>That's for VB, but worked like a charm for VFP too.
>>
>>Below is the working code:
>>
>>
>>
LPARAMETERS tcDestino, tcAssunto, tcHTML, tcArquivo, tcPicture
>>
>>LOCAL lcSchema, loConfig, loMsg, loError, lcErr
>>
>>  lcSchema = "http://schemas.microsoft.com/cdo/configuration/"
>>
>>  LOCAL loConfig as "CDO.Configuration"
>>  loConfig = CREATEOBJECT("CDO.Configuration")
>>
>>  WITH loConfig.FIELDS
>>
>>    .ITEM(lcSchema + "smtpserver") ="smtp.uol.com.br" && place your smtp here
>>    .ITEM(lcSchema + "smtpserverport") = "25"
>>    .ITEM(lcSchema + "sendusing") = 2
>>    .ITEM(lcSchema + "smtpauthenticate") = .T.
>>    .ITEM(lcSchema + "smtpusessl") = .F.
>>    .ITEM(lcSchema + "sendusername") = "login" && login
>>    .ITEM(lcSchema + "sendpassword") = "password" && your password
>>
>>    .UPDATE
>>
>>  ENDWITH
>>
>>
>>  LOCAL loMsg as "CDO.Message"
>>  loMsg = CREATEOBJECT ("CDO.Message")
>>
>>  WITH loMsg
>>
>>    .Configuration = loConfig
>>    .FROM = "Foxbrasil <foxbrasil@superfox.com.br>"
>>    .TO = tcDestino
>>    .Subject = tcAssunto
>>
>>	IF VARTYPE(tcArquivo) = "C" AND FILE(tcArquivo)
>>		loMsg.AddAttachment(tcArquivo) && Must be a valid file
>>	ENDIF
>>	
>>	#DEFINE CdoReferenceTypeName  1
>>	loMsg.AddRelatedBodyPart(lcArquivo, "pic", CdoReferenceTypeName)
>>	
>>*    .TextBody = "Here pur text"
>>
>>
>>* This is a test HTML showing how to use the emebedded image
>>    tcHTML = ="<html><img src='pic'></html>"
>>
>>
>>    .HTMLBody = tcHTML     .Send()
>>
>>  ENDWITH
>>
>>
>>
>>Regards
>>
>>Cesar
>>
>>
>>
>>
>>
>>
>>>It can be done with CDO 2000 which has CreateMHTMLBody() method.
>>>
>>>>I've been using CDOSys to send emails for some years, and now I'd like to add several images in the HTML code, but I'm having some troubles.
>>>>
>>>>I know I can publish the pictures on my web site and then just use an absolute link to them in the html code, like this, i.e., img src="http://mydomain.com/images/image.gif"
>>>>
>>>>But obviously this is not the best way to do, since for this case some pictures will be specific to each receiver.
>>>>
>>>>Can someone tell me how can I embed the image in the email body ? Preferrably, using CDOSYS.
>>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform