Inline Image Issue

  • Thread starter Thread starter dorutzu
  • Start date Start date
D

dorutzu

Hi,

I'm working on an Outlook Addin that has to send e-mails in HTML
format. I have the templates, they look great in the Outlook's
Inspectors (when sending for exemple), but the problem is that only I
(on my computer) can see the images in the e-mails, as they have links
on my hdd:
<IMG id=olhimg src="c:\addin\image.gif">
I notticed Outlook generates some src="cid:..." values for other
inline messages, but I didn't understand what's this about yet. Maybe
you can enlight me about this as well.
I also tryed (as I found in one example) to attach the
image(c:\addin\image.gif) to the e-mail, and make the link something
like src="cid:image.gif"...well, works in Outlook, but it doesn't on
Yahoo mail :((

So, all I want it my image to be embedded in the e-mail (not
somewhere on some public web-site), preferably without using
attachments.

Thanks,
Doru
 
Thank you for your quick response. I looked over the article you sent
me before I even posted this message(it seems that their server is
down at the moment, I can't access it)...the problem is I'm working in
VC++, and I don't know if I have access to CDO. And also, I don't know
too much VB, but do you think the same thing can be achived in VC++ as
well? And if yes, could you explain to me how?
BTW, is there any way I can have access to a MailItem's headers,
because I understood that in order to achive inseting inline images, I
have to deal with the e-mails headers...Please correct me if I'm
wrong.

Thank you,
Doru
 
If you're using VC++, then you can use Extended MAPI, which gives you access
to all the properties you might need to use.

BTW, nasty typo in my earlier URL post. Here's the correct one:
http://www.outlookcode.com/d/code/htmlimg.htm . Note the simplified method
and its caveats at the bottom of the pate.

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



dorutzu said:
Thank you for your quick response. I looked over the article you sent
me before I even posted this message(it seems that their server is
down at the moment, I can't access it)...the problem is I'm working in
VC++, and I don't know if I have access to CDO. And also, I don't know
too much VB, but do you think the same thing can be achived in VC++ as
well? And if yes, could you explain to me how?
BTW, is there any way I can have access to a MailItem's headers,
because I understood that in order to achive inseting inline images, I
have to deal with the e-mails headers...Please correct me if I'm
wrong.

Thank you,
Doru


"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
See http://www.outlook.code.com/d/code/htmlimg.htm

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Thank you. I found this article
http://www.dotnet247.com/247reference/msgs/29/147927.aspx
that helped me a lot (even if I'm using VC++ 6). Anyway, here is what
I came up with, but unfortunatelly, it's not working as it should be
(i'm using it in an Outlook Add-in):

//-------------------------------------------------------
//I have the newly created spNewMail...
USES_CONVERSION

CComVariant vEntryID;
CComPtr<Outlook::Attachments> spAttachments;
HRESULT hr = spNewMail->get_Attachments(&spAttachments);
if(FAILED(hr)) return;
if(spAttachments == NULL) return;

CComPtr<Outlook::Attachment> spAttach;
CComVariant vSource("C:\\The Addin\\Test2.gif");
CComVariant vType(olByValue);
CComVariant vPos(0);
CComVariant vDispName("myindent"); //in my html file, I have
something like <img src=cid:myindent border=0>
hr = spAttachments->Add(vSource, vType, vPos, vDispName, &spAttach);
if(FAILED(hr)) return;
if(spAttach == NULL) return;

spNewMail->put_Subject(T2W("Test subj"));

spNewMail->Close(olSave);
spNewMail->get_EntryID(&vEntryID.bstrVal);
spNewMail.Release();
spAttachments.Release();
spAttach.Release();


//the CDO part....
CComVariant comEntryID;
MAPI::_SessionPtr pMapiSession;
MAPI::MessagePtr pMapiMessage;
MAPI::AttachmentsPtr pMapiAttactments = NULL;
MAPI::AttachmentPtr pMapiAttactment = NULL;
MAPI::FieldsPtr pMapiFields;

pMapiSession.CreateInstance("MAPI.Session");
pMapiSession->Logon("Outlook");
CComVariant vEntryID2(vEntryID.bstrVal);
pMapiMessage = pMapiSession->GetMessage(vEntryID2);
pMapiAttactments = pMapiMessage->GetAttachments();
CComVariant v1(1);
pMapiAttactment = pMapiAttactments->GetItem(v1);
pMapiFields = pMapiAttactment->GetFields();
CComVariant vCdoPR(CdoPR_ATTACH_MIME_TAG);
CComVariant vImg("image/jpeg");
pMapiFields->Add(vCdoPR, vImg);
CComVariant v0x3(0x3712001E);
CComVariant vMyIndent("myindent");
pMapiFields->Add(v0x3, vMyIndent);
pMapiFields = pMapiMessage->GetFields();
CComVariant v080("{0820060000000000C000000000000046}0x8514");
CComVariant v11(11);
pMapiFields->Add(v080, v11, VARIANT_TRUE);
pMapiMessage->PutSubject(_T("Test Message from Outlook/VC++7"));
pMapiMessage->Update();
CComVariant vEntryID3(pMapiMessage->ID);

//and the grand finally
CComPtr<Outlook::_NameSpace> spNSmapi;
hr = m_spApp->GetNamespace(T2W("MAPI"), &spNSmapi);
if(FAILED(hr)) return;
if(spNSmapi == NULL) return;
CComPtr<IDispatch> spDispItem;
CComVariant vNull("");
spNSmapi->GetItemFromID(vEntryID3.bstrVal, vNull, &spDispItem);
if(spDispItem == NULL) return;

CComQIPtr<Outlook::_MailItem> spNewMail2(spDispItem);
if(spNewMail2 == NULL) return;

spNewMail2->put_BodyFormat(olFormatHTML); //html type
CString html = ReadHTMLIntoString((CString)W2T(bstrMSname));
spNewMail2->put_HTMLBody(T2W(html));

spNewMail2->Display();
spNewMail2.Release();
//-------------------------------------------------------

Any help would be greatly appreciated.

Thanks,
Doru
 
Back
Top