Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Embed images in emails
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01237212
Message ID:
01237973
Vues:
15
Thanks Mike, your suggestion works very nice too.

I just had to add a prefix "file://" before the file name, and everything works as desired.

Regards

Cesar


>I have done this in the past with CDO. What I use to do is create a HTML page with all the text an images in the right place, and make an MHTML page from that that places itself in the right place in the body of the e-mail using CreateMHTMLBody().
>
>
>>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.
>>>>>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform