Outlook-programmatically generating a new mail with images embedded in the message body

R

Rex King

Hi,
We need to call MS Outlook (2000 or later) from our Java application to
generate a new email, with images embedded in the body of the email.
The user then edits it further, or clicks send, to send it via outlook
the normal way. We're using a java wrapper to invoke Outlook, and so
far have succeeded in launching a new email with images attached to it.

Is there a way to programmatically embed the images within the body of
the mail itself?
We came across suggestions like using MAPI calls (which are registered
in cdo.dll). However, cdo.dll was not found on our own systems, where
we have Office XP and 2003 respectively installed. The solution we came
across recommended registering cdo.dll if it was not there.
However, only assumption we can make about the client environment is
that it has Outlook installed properly. We cannot expect cdo.dll to be
there, nor copy it and register it.
Is there any other way to do this?
 
S

Sue Mosher [MVP-Outlook]

You would have to install CDO.dll from the original OFfice/Outlook setup source.

If you don't have CDO, then you can still embed images but the image files will appear as normal attachments. See http://www.outlookcode.com/d/code/htmlimg.htm, specifically the Notes section.

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba
 
R

Rex King

Thanks for the help, we found some code on the site you mentioned and
modified it to do the job.
 
J

Jitin

Could you please explain what does &H3712001E represent in the
following line of code?

Set oField = colFields.Add(&H3712001E, "myident")

What type is &H3712001E? What could be the java equivalent for this
value?
 
J

Jitin

The code on the site http://www.outlookcode.com/d/c­ode/htmlimg.htm
worked for me when i use to create embedded email for Office XP but
would not work for Office 2003. I tried using cdo.dll of Outlook xp as
well as Outlook 2005 but none of them worked for Office 2003. Is there
some other code for embedding images in Outlook 2003?

Thanks
 
S

Sue Mosher [MVP-Outlook]

The code is not version-dependent. What in particular does not work?

Since there is no such thing as Outlook 2005, I'm a bit at a loss to know what you've actually done. A good first step would be to check your Outlook 2003 installation to see if CDO was included.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



The code on the site http://www.outlookcode.com/d/c­ode/htmlimg.htm
worked for me when i use to create embedded email for Office XP but
would not work for Office 2003. I tried using cdo.dll of Outlook xp as
well as Outlook 2005 but none of them worked for Office 2003. Is there
some other code for embedding images in Outlook 2003?

Thanks
 
S

Sue Mosher [MVP-Outlook]

Maybe you could post an example from a message showing the <img> tag?
 
J

Jitin

<p class=MsoNormal><img width=32 height=32 id="_x0000_i1025"
src="cid:ABDOMEN_VOLUNTEER_Series#_20_Image#_1.jpg@12" align=baseline
border=0><o:p></o:p></p

I am surprised, this same tag works for outlook xp but wont work for
outlook 2003. I tried running the code with cdo.dll of both xp and
2003. :(
 
S

Sue Mosher [MVP-Outlook]

Thanks. So, let's now see your code snippet where you add the attachment and set the property for its CID.

Also note: The newsgroup interface you are using apparently does not quote earlier messages in the thread, making your latest message so short on detail that you risk not getting the answer you're looking for. Please take the time to quote the original message.
 
J

Jitin

So here is what i am doing. I am using the same code as given on
http://www.outlookcode.com/d/code/htmlimg.htm and want it to work with
Outlook 2003. I've added cdo 1.21 library and outlook 11.0 library in
the project references. Now the problem is that the image gets embedded
only when Outlook is running, otherwise you get a missing image icon in
the body of the mail.

Now we want to use this code with Outlook 2003. For this I create
wrapper classes for the outlook 2003 dll as well as the cdo.dll file.
When i run the java code, the image gets embedded properly at certain
times, and not at other times-i.e. it works unpredictably. There is no
fixed pattern when the image would embed or not.
Using the same code with the same DLLs however works properly if you
use Outlook XP, i.e.

Could you please help me out on this?
 
S

Sue Mosher [MVP-Outlook]

Java code? "only when Outlook is running"? Sounds like there are a few details that you're not giving us the full story about?

What do you get for the <img> tag and the actual CID in the RFC822 header? Look on the received message, using a mailer like Outlook Express that can show the full message source.

Also note: The newsgroup interface you are using apparently does not quote earlier messages in the thread, making your latest message so short on detail that you risk not getting the answer you're looking for. Please take the time to quote the original message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top