How to embed a picture (logo) in an e-mail for use in a HTML signature?

I’m trying to append customised (per person) signatures containing our company logo to outgoing e-mails.

I have created a template HTML file for the signatures, but the graphic (the logo) will only display in a browser and not when a mail message is composed in Notes. Obviously, I need to include the (very small) logo graphic within the e-mail.

If I import the graphic manually, it does appear when the message is received, but I really need it to be included automatically. I need the picture to be accessible to the signature when it appears in the recipients inbox without the user having to add it each time.

Anyone able to assist?

Paul.

Subject: How to embed a picture (logo) in an e-mail for use in a HTML signature?

This is interesting as I do not allow incoming Internet e-mail to display images at all if I can control this for a number of reasons.

You might want to consider that many end-users do this for privacy reasons and ask yourself if it is indeed worth the effort.

Subject: RE: How to embed a picture (logo) in an e-mail for use in a HTML signature?

Hi Christopher,

I’m not sure what this has to do with privacy issues - can you explain?

The effect I’m trying to achieve is like that of a Notes Letterhead, except that it will work with non-Notes mail clients. I receive some e-mail in this format myself from companies I regularly deal with. I don’t want the graphic to be downloaded upon opening of the message (which might be construed as a way of counting the number of read e-mails) but included in the e-mail (as part of a multipart message?) and thus accessible to the signature.

Regards,

Paul.

Subject: RE: How to embed a picture (logo) in an e-mail for use in a HTML signature?

The privacy issues surround the growing use of embedded graphics to track users behavior on the internet if they are blocking cookies…a very nasty practice indeed, but so simple in its elegance and implementation.

Subject: RE: How to embed a picture (logo) in an e-mail for use in a HTML signature?

This is a different issue. These are not embedded images, these are URL references, and the privacy issues have to do with the URL being used to access the image, and the retrieval being tracked to identify the reader. Embedded images in an e-mail have separate “related” MIME parts, and so don’t have to reach out to the Internet and have no privacy issue.

Subject: RE: How to embed a picture (logo) in an e-mail for use in a HTML signature?

“Embedded images in an e-mail have separate “related” MIME parts, and so don’t have to reach out to the Internet and have no privacy issue.”

Ben, it sounds like this is what I need to find out about. How do I include the image (a related MIME part?) that is accessible to the signature? How do I append this automatically to all e-mails? If I add it via the mail template, where?

Thankyou,

Paul.

Subject: RE: How to embed a picture (logo) in an e-mail for use in a HTML signature?

Well, if you can wait a few weeks, our soon-to-be-released COEX! Mail product will support adding disclaimers along with conversion to MIME and a bunch of other related stuff (e.g., turning doclinks into NDL attachments or Notes URLs the way our CoexLinks product does, but converting to MIME to make true link hotspots, etc.) If you can’t wait, you will need to look into the NotesMIMEEntity class and prepare for some reasonably heavy learning about Base64 encoding and MIME manipulation.

Note: Updated Oct. 14, 2004 to reflect change of name from COEX! Links to CoexLinks

Subject: RE: How to embed a picture (logo) in an e-mail for use in a HTML signature?

Ben,

As far as I can tell, I’ve managed to add the image as an inline MIME part with the following code. However, I still have two issues:

(1) I’ve tried placing the code in a number of the form events (QuerySave, Queryclose etc…) so that the graphic is added during document creation, but for some reason the MIME Part only becomes visible (the message size increases and an item appears in the Document properties) after opening and closing (or resaving, depending on the form event) the delivered document for the first time. When the message first arrives in the Inbox, there is no MIME Part (judging by the file size & properties).

(2) I can’t get the picture to display in my signature! I’m not sure how to reference the Content-ID in my HTML code (already tried ‘img src = cid:logo.bmp’). If I change the content disposition to ‘attachment’, I can view the image ok, so it must just be a linkage issue (?).

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim nMIMEEnt As NotesMIMEEntity

Dim header As NotesMIMEHeader

Dim db As NotesDatabase

Dim stream As NotesStream

Dim FileName As String

Dim workspace As New NotesUIWorkspace

Dim ses As New NotesSession

Set db = ses.CurrentDatabase

ses.ConvertMIME = False

Set uidoc = workspace.CurrentDocument

Set doc = uidoc.Document

Set nMIMEEnt = doc.GetMIMEEntity(“CompanyLogo”)

If (nMIMEEnt Is Nothing) Then

Set nMIMEEnt = doc.CreateMIMEEntity("CompanyLogo")

Set header = nMIMEEnt.CreateHeader("Content-Disposition")

Call header.SetHeaderVal("inline; filename=logo.bmp")

Set header = nMIMEEnt.CreateHeader("Content-ID")

Call header.SetHeaderVal("<logo.bmp>") <- also tried "logo.bmp"

Set header = nMIMEEnt.CreateHeader("Content-Transfer-Encoding")

Call header.SetHeaderVal("Base64")

Set stream = ses.CreateStream()

FileName = "c:\logo.bmp"

Call stream.Open(FileName)

Call nMIMEEnt.SetContentFromBytes(stream,"image/bmp",ENC_NONE)

Call nMIMEEnt.EncodeContent(ENC_BASE64)

Call stream.close

Call doc.CloseMIMEEntities(True)

Call doc.Save(True,False,True)

End If

MIME Part properties:

Field Name: CompanyLogo

Data Type: MIME Part

Data Length: 165 bytes

Seq Num: 2

Dup Item ID: 0

Field Flags: SIGN SEAL

"Content-Transfer-Encoding: binary

Content-Type: image/bmp

Content-Disposition: inline;

filename=logo.bmp

Content-ID: <logo.bmp>

logo.bmp"

Got any ideas?

Paul.

Subject: RE: How to embed a picture (logo) in an e-mail for use in a HTML signature?

I think the problem is the lines:

Set header = nMIMEEnt.CreateHeader("Content-Disposition")

Call header.SetHeaderVal("inline; filename=logo.bmp")

which do not match what we create when we actually use the MIME part. Just comment out those lines. Also, you specify:

‘img src = cid:logo.bmp’

when I assume you mean:

‘img src=cid:logo.bmp’

without the spaces. Assuming this format, you should specify the Content-ID with the <> format, as you suggest:

Set header = nMIMEEnt.CreateHeader("Content-ID")

Call header.SetHeaderVal("<logo.bmp>")

We actually use a longer format, but this should work, except that .BMP formats aren’t very portable, so you should use a GIF or JPEG format.

Subject: RE: How to embed a picture (logo) in an e-mail for use in a HTML signature?

Ben,

I have tried removing those couple of lines of code, converting the bitmap to a jpg and changing the cid reference (no spaces), but it still won’t work.

Thanks for your help regardless,

Paul.

Subject: Is there a programmatic way to trim off the image’s query parameters?

I generally don’t open HTML e-mails (judging by their size) for this same reason.

I was wondering about writing an agent to trim off the query parameters after an image url. Some messages will be easy to decode, but unfortunately I don’t have enough experience decoding with MIME.

Subject: RE: Is there a programmatic way to trim off the image’s query parameters?

These really aren’t “query parameters”, they are the source for the image itself. Here is an example:

OK image

Not OK image

What is the difference? Well, the long random string of characters “78A26D287E673q587R623873v4658742” is different for every e-mail. The target server will serve up the image anyway, so you can’t tell, but since they know about every request, they now know you opened up the image. But could you stop that? Depends on whether you think you are smart enough to know when it is a “query” and when it is just a UNID style string used to access the image. Usually, the only choice is to not get the images at all, and it is possible to have a tool that does that, or to turn off image retrieval one way or another.

Subject: I didn’t realize that spammers tracked items this way.

I guess I need to think more like a crook!

I thought they used parameters after the image: http://www.spammerzone.com/imgs/psych.jpg?open&refid=12341312

Subject: Yup, most insidious! (WAS: I didn’t realize that spammers tracked items this way)

Nasty isn’t it? When I get these spams in Notes, I just delete them without opening them (woe betide anyone I don’t know sending me mail at work!)

Of course, most modern mail systems combat this by doing something like this (OS X Mail & Outlook 2003 spring to mind):

If the app considers the mail to be a spam candidate, doesn’t load the images

User selects whether images are loaded or not

I wonder if one could make this controllable in a tweaked Notes mail template…

Subject: Is Mail.app and IMAP the answer?

I have been debating whether to use IMAP and the MacOS X mail.app. It seems that Mail handles spam better, but then again, I vasilate between developing on a Mac via Remote Desktop Connection/PC and a PC notebook (now known as the POS). If I’m heavy into development, I’ll use the POS. If I’m just tweaking a few items, then my PowerBook and I are not separated.

Subject: RE: Is Mail.app and IMAP the answer?

I’d never come between a man and his Powerbook :wink: mail.app in Panther offers the image blocking option when dealing with spam.

Subject: RE: I didn’t realize that spammers tracked items this way.

A few do, but those are just too obvious. I have a colleague who works with anti-spam software (spamJam), and I have learned a lot from him about how these work. It changes all the time though, so no matter how hard you work, you are always just catching up to new techniques.