This project is read-only.

Embed a logo in an email message

Topics: Enhancement Request, General
May 19, 2011 at 4:04 PM

I am working on a project that involves embedding a companies logo into an email message. The current implementation sends an email to a given email address with a message pertaining a sales order. I need to embed the image at the top of this email. I have searched over the Internet and none of the solutions have seemed to help me out. Can anyone help me?

Thanks

Aug 2, 2011 at 6:14 PM

There is an extension for google chrome that creates a single 'html' file of a webpage by 'embeding' image resources encoded in base64Binary. Those files are opened by any browser so i suppose there is a specification somewhere on w3c about this. I think that the same technique could be used to embed an image into the html body of an email.

Hope this helps.

Aug 3, 2011 at 4:23 PM
Edited Aug 3, 2011 at 4:29 PM

Have you tried CDO? I have a solution in my app to send email and it works,  and I know that it can send embedded content. But my approaching to send embedded content is not working for some reason, it embeds the file but it is shown as a broken link in the recipient mail client. Maybe is a silly thing I'm missing, but I haven't been able to find what is. By the Way, the code I'm using could be of any help for you and perhaps you can find the missing piece and get what you are looking for.

You can find documentation on CDO at http://msdn.microsoft.com/en-us/library/ms526453

I made this example based on the post from Yamaharuss made in Visual Basic at http://www.webdeveloper.com/forum/showpost.php?p=856441&postcount=5

***********************************************************************************

 

*Server Configuration
CdoReferenceTypeName = 1
oconf=CREATEOBJECT("cdo.configuration")
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing").Value = 2
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value = "YourSMTPServerHere"
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport").Value = 25
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout").Value = 10
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value = 1 &&0 No Auth, 1 Simple Authentication, 2 NTLM
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername").Value = "SMPT User Name"
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword").Value = "SMP Password"
*The following line only if your SMTP Server Requires SSL Connection
*oconf.Fields.Item(http://schemas.microsoft.com/cdo/configuration/smtpusessl).Value = .T.
oconf.Fields.Update

*Create the message
ocdo=CREATEOBJECT("cdo.message")
ocdo.Configuration = oconf
ocdo.To = "destinationemail@anydomain.com"
ocdo.From = "senderemail@anydomain.com"
ocdo.Subject = "The Subject of the message"
ocdo.MimeFormatted= .T.
ocdo.HTMLBody = [<html>See Foxpro Logo!!: <img src=""cid:vfplogo.gif""></html>]
*The example file is c:\temp\vfpfile.gif
oBP = ocdo.AddRelatedBodyPart("c:\temp\vfplogo.gif", "vfplogo.gif", CdoReferenceTypeName)
oBP.Fields.Item("urn:schemas:mailheader:Content-ID") = "<vfplogo.gif>"
oBP.Fields.Update
ocdo.Send

***************************************************************************************************

 

Cheers

Jairo R.

Aug 3, 2011 at 4:46 PM

Actually the error was very stupid. I was using double quotation marks in the image source. Below is the corrected code:

***************************************************************************************************

 

*Server Configuration
CdoReferenceTypeName = 1
oconf=CREATEOBJECT("cdo.configuration")
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing").Value = 2
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value = "YourSMTPServerHere"
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport").Value = 25
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout").Value = 10
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value = 1 &&0 No Auth, 1 Simple Authentication, 2 NTLM
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername").Value = "SMPT User Name"
oconf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword").Value = "SMP Password"
*The following line only if your SMTP Server Requires SSL Connection
*oconf.Fields.Item(http://schemas.microsoft.com/cdo/configuration/smtpusessl).Value = .T.
oconf.Fields.Update

*Create the message
ocdo=CREATEOBJECT("cdo.message")
ocdo.Configuration = oconf
ocdo.To = "destinationemail@anydomain.com"
ocdo.From = "senderemail@anydomain.com"
ocdo.Subject = "The Subject of the message"
ocdo.MimeFormatted= .T.
*The following line was corrected
ocdo.HTMLBody = [<html>See Foxpro Logo!!: <img src="cid:vfplogo.gif"></html>]
*The example file is c:\temp\vfpfile.gif
oBP = ocdo.AddRelatedBodyPart("c:\temp\vfplogo.gif", "vfplogo.gif", CdoReferenceTypeName)
oBP.Fields.Item("urn:schemas:mailheader:Content-ID") = "<vfplogo.gif>"
oBP.Fields.Update
ocdo.Send

***************************************************************************************************

Hope this helps