Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Embed an Image into Body HTML
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01587392
Message ID:
01587414
Vues:
39
Hi Luis. Thanks for replying
I see you are using CDO, whcih I am not using to send the Email, and I need to build up the Body text in HTML Code

================================================================
*--- Embedded image file
loBP = .AddRelatedBodyPart( HOME(1) + "fox.bmp", "fox-image-bmp", 1)
WITH loBP
.FIELDS.ITEM("urn:schemas:mailheader:Content-ID") = "fox-image-bmp"
.FIELDS.UPDATE
ENDWITH
================================================================
What does above code do ?
Can this be written in Plain HTML in the body of the HTML as I wont have a loBP ?

Regards,
Gerard




>>Hi.
>>I am trying to embed an image (dont want the image linked to a server) in the body of an email
>>I create the HTML page with the various tags but cannot get the Image to imbed
>>I know I have to use img src="cid:MyFilename" but not sure if this is ALL thats required or do I need additional code to attach the image also?
>>Also , do I need to point to the absolute file reference in MyFileName or is this done somewhere else ?
>>
>>Lots of sample using PHP out there , but has anybody had a sample of HTML code that embeds a file
>>(The embedded file will either be a signature or a company logo that is appers near or at the end of the email text)
>>Tia
>>Gerard
>
>See and run this example (change for valid MY_USER, MY_PASSWORD and TO_USER)
>
>
>TRY
>  LOCAL lcSchema, loConfig, loMsg, loError, lcErr
>  lcErr = ""
>  lcSchema = "http://schemas.microsoft.com/cdo/configuration/"
>  loConfig = CREATEOBJECT("CDO.Configuration")
>  WITH loConfig.FIELDS
>    .ITEM(lcSchema + "smtpserver") = "smtp.gmail.com"
>    .ITEM(lcSchema + "smtpserverport") = 465 && ó 587
>    .ITEM(lcSchema + "sendusing") = 2
>    .ITEM(lcSchema + "smtpauthenticate") = .T.
>    .ITEM(lcSchema + "smtpusessl") = .T.
>    .ITEM(lcSchema + "sendusername") = "MY_USER@gmail.com"
>    .ITEM(lcSchema + "sendpassword") = "MY_PASSWORD"
>    .UPDATE
>  ENDWITH
>  loMsg = CREATEOBJECT ("CDO.Message")
>  WITH loMsg
>    .Configuration = loConfig
>    .FROM = "MY_USER@gmail.com"
>    .TO = "TO_USER@gmail.com"
>    .Subject = "Prueba desde Gmail " + TIME()
>
>*** Note: Remove the spaces below the symbol  < to the tags p> /p> and img
>*** I know no other way to put the correct HTML code :-(
>
>    TEXT TO lcBody noshow PRETEXT 7
>    < p>Ejemplo de imagen embebida< /p>
>    < p>< img src="cid:fox-image-bmp">< /p>
>    ENDTEXT
>
>    .HTMLBody = lcBody
>
>    *--- Embedded image file
>    loBP = .AddRelatedBodyPart( HOME(1) + "fox.bmp", "fox-image-bmp", 1)
>    WITH loBP
>      .FIELDS.ITEM("urn:schemas:mailheader:Content-ID") = "fox-image-bmp"
>      .FIELDS.UPDATE
>    ENDWITH
>
>    .SEND()
>  ENDWITH
>CATCH TO loError
>  lcErr = [Error: ] + STR(loError.ERRORNO) + CHR(13) + ;
>    [Linea: ] + STR(loError.LINENO) + CHR(13) + ;
>    [Mensaje: ] + loError.MESSAGE
>FINALLY
>  RELEASE loConfig, loMsg
>  STORE .NULL. TO loConfig, loMsg
>  IF EMPTY(lcErr)
>    MESSAGEBOX("El mensaje se envió con éxito", 64, "Aviso")
>  ELSE
>    MESSAGEBOX(lcErr, 16 , "Error")
>  ENDIF
>ENDTRY
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform