By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,607 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,607 IT Pros & Developers. It's quick & easy.

How does Outlook embed pictures in emails??

P: n/a
Siv
Hi,

I have written an application which is used by sales staff when discussing
products with their customers over the phone. It is a database application
that holds detailed information about their products including pictures to
assist the sales staff describe features to the customer. The next step in
development of the app is to have a button when in a particular product
screen that the seller can press which sends the customer an email with the
picture embedded in an HTML format Outlook message. I have got it to work
superbly, the email is constructed by the application and sent to the outbox
ready for send and receive and looks fine. When the mail is sent however, I
find that the picture is replace by a place holder "X" symbol indicating the
picture was not found.

My initial thoughts were that I hadn't got the "Send Pictures from the
Internet" option ticked, but even when it is, the picture is still missing.

When I look at an email sent to me from someone where the picture was
inserted into the body text of the message, the image is not mentioned as a
link in normal "img" style format it looks like this:

<DIV>
<FONT face=Arial size=2>
<SPAN class=866055209-20072005>
<IMG alt=chesham hspace=0 src="cid:866055209@20072005-2abd" align=baseline
border=0>
</SPAN>
</FONT>
</DIV>

Does anyone know how you can do this programmatically as I suspect if I just
copy the above HTML code it won't work as the "cid:866055209@20072005-2abd"
is probably specific to the individual instance of the picture sent to me,
it is clearly constructed using the date (UK format). I really need to
understand how Outlook constructs that code and embeds the picture and
indeed if there is a process I can call programmatically that does the
erquivalent of a user embedding the picture manually.

I currently do the following in code:
I have some declarations at the top of the class module:

Private OApp As Outlook.Application
Private email As Outlook.MailItem
Private oNameSpace As Outlook._NameSpace
Private oOutboxFolder As Outlook.MAPIFolder

Then in the subroutine that hangs off a small form that allows the user to
enter the adressee's email and message subject line I have (removed try
catch block and error checking for simplicity):

Dim EmailAddress, ToAddress, BodyHTML, Salutation As String

EmailAddress = txtEmail.Text
Salutation = txtSalutation.Text

OApp = New Outlook.Application
oNameSpace = OApp.GetNamespace("MAPI")
oNameSpace.Logon("outlook", "", False, False)
oOutboxFolder =
oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolde rs.olFolderOutbox)

... here I construct a string called BodyHTML which is just the
HTML code for the message body ..

email = OApp.CreateItem(OlItemType.olMailItem)
email.To = EmailAddress
email.Subject = "Details of the Item you requested."
email.HTMLBody = BodyHTML
email.Send()

I need to find out how to build the HTML string so that the picture is
embedded not left behind on the user's PC.

Thanks for any help.

--
Siv
Martley, Near Worcester, UK.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Siv,
Here is an example (requires CDO or Redemption) to add an embedded image
file to a message.

http://www.outlookcode.com/d/code/htmlimg.htm

Hope this helps
Jay

"Siv" <ms**********@removeme.sivill.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
| Hi,
|
| I have written an application which is used by sales staff when discussing
| products with their customers over the phone. It is a database
application
| that holds detailed information about their products including pictures to
| assist the sales staff describe features to the customer. The next step
in
| development of the app is to have a button when in a particular product
| screen that the seller can press which sends the customer an email with
the
| picture embedded in an HTML format Outlook message. I have got it to work
| superbly, the email is constructed by the application and sent to the
outbox
| ready for send and receive and looks fine. When the mail is sent however,
I
| find that the picture is replace by a place holder "X" symbol indicating
the
| picture was not found.
|
| My initial thoughts were that I hadn't got the "Send Pictures from the
| Internet" option ticked, but even when it is, the picture is still
missing.
|
| When I look at an email sent to me from someone where the picture was
| inserted into the body text of the message, the image is not mentioned as
a
| link in normal "img" style format it looks like this:
|
| <DIV>
| <FONT face=Arial size=2>
| <SPAN class=866055209-20072005>
| <IMG alt=chesham hspace=0 src="cid:866055209@20072005-2abd" align=baseline
| border=0>
| </SPAN>
| </FONT>
| </DIV>
|
| Does anyone know how you can do this programmatically as I suspect if I
just
| copy the above HTML code it won't work as the
"cid:866055209@20072005-2abd"
| is probably specific to the individual instance of the picture sent to me,
| it is clearly constructed using the date (UK format). I really need to
| understand how Outlook constructs that code and embeds the picture and
| indeed if there is a process I can call programmatically that does the
| erquivalent of a user embedding the picture manually.
|
| I currently do the following in code:
| I have some declarations at the top of the class module:
|
| Private OApp As Outlook.Application
| Private email As Outlook.MailItem
| Private oNameSpace As Outlook._NameSpace
| Private oOutboxFolder As Outlook.MAPIFolder
|
| Then in the subroutine that hangs off a small form that allows the user
to
| enter the adressee's email and message subject line I have (removed try
| catch block and error checking for simplicity):
|
| Dim EmailAddress, ToAddress, BodyHTML, Salutation As String
|
| EmailAddress = txtEmail.Text
| Salutation = txtSalutation.Text
|
| OApp = New Outlook.Application
| oNameSpace = OApp.GetNamespace("MAPI")
| oNameSpace.Logon("outlook", "", False, False)
| oOutboxFolder =
| oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolde rs.olFolderOutbox)
|
| ... here I construct a string called BodyHTML which is just the
| HTML code for the message body ..
|
| email = OApp.CreateItem(OlItemType.olMailItem)
| email.To = EmailAddress
| email.Subject = "Details of the Item you requested."
| email.HTMLBody = BodyHTML
| email.Send()
|
| I need to find out how to build the HTML string so that the picture is
| embedded not left behind on the user's PC.
|
| Thanks for any help.
|
| --
| Siv
| Martley, Near Worcester, UK.
|
|
Nov 21 '05 #2

P: n/a
Siv
Jay,
Many thanks for this, I will pour over it and see if I can a) get my head
round it and b) implement it. Initial look seems to be exactly what I need.
Thanks again.
--
Siv
Martley, Near Worcester, UK.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eR**************@TK2MSFTNGP10.phx.gbl...
Siv,
Here is an example (requires CDO or Redemption) to add an embedded image
file to a message.

http://www.outlookcode.com/d/code/htmlimg.htm

Hope this helps
Jay

"Siv" <ms**********@removeme.sivill.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
| Hi,
|
| I have written an application which is used by sales staff when
discussing
| products with their customers over the phone. It is a database
application
| that holds detailed information about their products including pictures
to
| assist the sales staff describe features to the customer. The next step
in
| development of the app is to have a button when in a particular product
| screen that the seller can press which sends the customer an email with
the
| picture embedded in an HTML format Outlook message. I have got it to
work
| superbly, the email is constructed by the application and sent to the
outbox
| ready for send and receive and looks fine. When the mail is sent
however,
I
| find that the picture is replace by a place holder "X" symbol indicating
the
| picture was not found.
|
| My initial thoughts were that I hadn't got the "Send Pictures from the
| Internet" option ticked, but even when it is, the picture is still
missing.
|
| When I look at an email sent to me from someone where the picture was
| inserted into the body text of the message, the image is not mentioned
as
a
| link in normal "img" style format it looks like this:
|
| <DIV>
| <FONT face=Arial size=2>
| <SPAN class=866055209-20072005>
| <IMG alt=chesham hspace=0 src="cid:866055209@20072005-2abd"
align=baseline
| border=0>
| </SPAN>
| </FONT>
| </DIV>
|
| Does anyone know how you can do this programmatically as I suspect if I
just
| copy the above HTML code it won't work as the
"cid:866055209@20072005-2abd"
| is probably specific to the individual instance of the picture sent to
me,
| it is clearly constructed using the date (UK format). I really need to
| understand how Outlook constructs that code and embeds the picture and
| indeed if there is a process I can call programmatically that does the
| erquivalent of a user embedding the picture manually.
|
| I currently do the following in code:
| I have some declarations at the top of the class module:
|
| Private OApp As Outlook.Application
| Private email As Outlook.MailItem
| Private oNameSpace As Outlook._NameSpace
| Private oOutboxFolder As Outlook.MAPIFolder
|
| Then in the subroutine that hangs off a small form that allows the user
to
| enter the adressee's email and message subject line I have (removed try
| catch block and error checking for simplicity):
|
| Dim EmailAddress, ToAddress, BodyHTML, Salutation As String
|
| EmailAddress = txtEmail.Text
| Salutation = txtSalutation.Text
|
| OApp = New Outlook.Application
| oNameSpace = OApp.GetNamespace("MAPI")
| oNameSpace.Logon("outlook", "", False, False)
| oOutboxFolder =
| oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolde rs.olFolderOutbox)
|
| ... here I construct a string called BodyHTML which is just
the
| HTML code for the message body ..
|
| email = OApp.CreateItem(OlItemType.olMailItem)
| email.To = EmailAddress
| email.Subject = "Details of the Item you requested."
| email.HTMLBody = BodyHTML
| email.Send()
|
| I need to find out how to build the HTML string so that the picture is
| embedded not left behind on the user's PC.
|
| Thanks for any help.
|
| --
| Siv
| Martley, Near Worcester, UK.
|
|

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.