FYI: Eingebundene Bilder in Outlook-HTML-Mail / embedded graphics in HTML


hier mal eine vollst�ndige L�sung zum Versenden einer HTML-Mail mit
eingebundenen Bildern aus Outlook 2000.
Die L�sungsans�tze sind aus verschiedenen NG's.
Es ist kein CDO-Verweis notwendig!
VBA-Code in MS-Access 2000

Here a complete solution for sending a HTML mail with embedded graphics via
Outlook 2000.
The methods of solution are from different NG's.
You don't need the CDO reference!
VBA-Code with MS-Access 2000

'--- Start of Code ---
Public Function sendOLEmbeddedHTMLGraphic(strSendTo As String, _
                                          Optional strSendCC As Variant, _
                                          Optional strSendBCC As Variant, _
                                          Optional strSubject As Variant, _
                                          Optional strBody As Variant, _
                                          Optional varAttachement As
' Versenden einer HTML-Mail mit mehreren eingebetteten Bildern via Outlook.
' Zur Info:
' Das Versenden funktioniert nicht mit Base64-eingebundenen IMG, da das der
IE (und damit OL) nicht unterst�tzt.
' Daher folgende L�sung als Ausgangsbasis:
' To add an embedded image to an HTML message
' This technique by Outlook  MVP Neo uses undocumented MAPI properties and
CDO to add an embedded image file
' to a message and set the CID so th   at an HTMLBody property <img> tag can
set that image as the sourc.
' In VBA or Visual Basic, you will need to add a reference to the CDO 1.21
library to use this procedure.
' varAttachement: Die Bilder werden als Anhang in einem Array �bergeben
' strBody:        Enh�lt den HTML-Code incl. aller <IMG>-Tags incl.
'                 cid in strBody und hier im Code m�ssen zusammenpassen
' Ein Verweis auf die CDO 1.21 Library ist wg. Latebinding nicht notwendig!
' Codeanleihen auch von Henry Habermacher aus der NG
' vom 29. Jan. 2004 zum Thema OL-Mail (Function sendOLMail).
' Stefan Wirrer, Volke Consulting Engineers GmbH, M�nchen, Deutschland
' Erstellt am 10.08.2006, Stand: 10.08.2006

   Dim olApp         As Object
   Dim olItem        As Object
   Dim CDOSession    As Object
   Dim CDOMessage    As Object
   Dim CDOFields     As Object
   Dim CDOField      As Object
   Dim strEntryID    As String
   Dim strCID        As String
   Dim strAttach     As String
   Dim lngI          As Long
   Dim intPos1       As Integer
   Dim intPos2       As Integer

   Const olMailItem  As Integer = 0
   Const olSave      As Integer = 0
   Const CdoPR_ATTACH_MIME_TAG = 923664414

   '-- create new Outlook MailItem
   Set olApp = CreateObject("Outlook.Application")
   Set olItem = olApp.CreateItem(olMailItem)

   olItem.To = Nz(strSendTo, "")
   olItem.CC = Nz(strSendCC, "")
   olItem.bcc = Nz(strSendBCC, "")
   olItem.Subject = Nz(strSubject, "")

   For lngI = LBound(varAttachement) To UBound(varAttachement)
      If Len(varAttachement(lngI)) > 0 Then
         '-- add graphic as attachment to Outlook message, change path to
graphic as needed
         strAttach = CStr(varAttachement(lngI))
         olItem.Attachments.Add strAttach

         olItem.Close olSave
         strEntryID = olItem.EntryID
         Set olItem = Nothing

         '-- initialize CDO session
         Set CDOSession = CreateObject("MAPI.Session")
         CDOSession.Logon "", "", False, False

         '-- get the message created earlier
         Set CDOMessage = CDOSession.GetMessage(strEntryID)

         '-- CID-Name = "myident" + Dateiname des Anhangs ohne Endung
         intPos1 = InStrRev(Replace(strAttach, "/", "\"), "\") + 1
         intPos2 = InStrRev(strAttach, ".") - 1
         strCID = Mid(strAttach, intPos1, Len(strAttach) - intPos2)
         strCID = "myident" & strCID

         '-- set properties of the attached graphic that make
         '   it embedded and give it an ID for use in an <IMG> tag
         Set CDOFields = CDOMessage.Attachments.Item(lngI).Fields
         Set CDOField = CDOFields.Add(CdoPR_ATTACH_MIME_TAG, "image/jpeg")
         Set CDOField = CDOFields.Add(&H3712001E, strCID)
         CDOMessage.Fields.Add "{0820060000000000C000000000000046}0x8514",
11, True

         '-- get the Outlook MailItem again
         Set olItem = olApp.GetNamespace("MAPI").GetItemFromID(strEntryID)
         olItem.Close (olSave)
      End If

   '-- add HTML content -- the <IMG> tag
   'olItem.HTMLBody = "<IMG align=baseline border=0 hspace=0
   olItem.HTMLBody = strBody

   '-- display the mail


   '-- clean up objects
   Set CDOField = Nothing
   Set CDOFields = Nothing
   Set CDOMessage = Nothing
   Set CDOSession = Nothing
   Set olApp = Nothing
   Set olItem = Nothing

   End Function
'--- End of Code ---

aus M�nchen

Infos f�r Neulinge in den Access-Newsgroups:

news430 (2)
8/17/2006 11:45:41 AM
outlook 87535 articles. 11 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 23

Hallo Stefan

quoting Stefan Wirrer:
> ' Codeanleihen auch von Henry Habermacher aus der NG
> ' vom 29. Jan. 2004 zum Thema OL-Mail (Function sendOLMail).

Ist aber schon lange her ;-)
Inzwischen ist CDO ins Alter gekommen und nicht mehr so ohne weiteres 
�berall Lauff�hig.
Ich selber verwende statt dessen inzwischen ein selbstgestricktes SMTP 
SendMail Modul, welches HTML Mails versenden kann ;-) Dann geht's ohne CDO, 
rein mit VBA und API, inkl. Plain und Auth Login Authentification.
N�chster Schritt wird dann der einsatz von .Net sein. Dort gibt's ja mehr 
oder weniger schon alles vorgefertigt.



Wichtig: Anmeldetermin f�r die AEK (siehe FAQ) nicht verpassen!
Keine E-Mails auf Postings in NGs senden!
FAQ: (neu mit Suchfunktion!)
OH:  Online Hilfe von Microsoft Access (Taste F1)

8/17/2006 1:25:46 PM

Similar Artilces:

Can I send a recurring e-mail automatically each week
I want to send a e-mail with the same verbiage to the same person once a week and make it a recurrence with no end date. Can I set this up once in Outlook so it is scheduled automatically? -- Microsoft Office 2003 Version Students and Teachers Edition Windows Vista Home Premium Thank-you Happy new Year!! Carl R ...

Crash on 'Send"
My wife's Intel Celeron running ME started having this problem sporadically - now constantly. Outlook 2000 receives OK - everything seems fine until you hit the 'Send' button then Outlook crashes giving an error message that says 'Outlook has caused an error in <unknown> and has to shut down. If the problem persists you may have to restart your computer.' Re-starting however has no effect. I have re-installed Office. Used 'Detect & Repair' under the 'Help' tab, and installed all patches/updates from the Office site. But this error continues, now...

Transferring over outlook data to new XP machine
How do I transfer over my old emails, address book to my new XP machine? I have looked over the internet and found nothing the tells me EXACTLY how to do this, any help would be greatly appreciated. If your using MS Outlook copy your .PST file across and import it into the new install. >If your using MS Outlook copy your .PST file across and import it into the new install. No, don't import it. Simply use "File">"Open" -- Brian Tillman Smiths Aerospace 3290 Patterson Ave. SE, MS 1B3 Grand Rapids, MI 49512-1991 Brian.Tillman is the nam...

Outlook 2003 and "Check Names"
Hi, We are testing Outlook 2003 at our office now and there is one very frustrating "feature" that is bugging all of us. When we create a new e-mail message and type in the first name of a person from the global address book and hit ctrl- k to check the name...we get a response that Outlook doesn't recognize the name and there are "no suggestions". The only way Check Name will successfully resolve the name is if we type it last name first (ie, Gates, Bill). This was not the case in Office XP or Outlook 2000. You could search by first name (or partial first name)...

Outlook 2003 keeps crashing #2
I get this message when I look in System information. Outlook keeps crashing quite often. I cannot for example delete two messages without outlook crashing. My colleagues do not have this problem. We are using the Microsoft mail exhange server. Faulting application outlook.exe, version 11.0.5510.0, stamp 3f1380f0, faulting module mso.dll, version 11.0.5606.0, stamp 3f334cce, debug? 0, fault address 0x003b6e16. Does anyone has a solution?=20 Best regards/ Bj=F6rn 1) I would definitely apply Service Pack 2for Office 2003 + applicable critical security updates. 2) Have you tried starting O...

Recieve Mail Before Sending
How do I set up Outlook 2003 to recieve mail before sending Set your send/receive group settings to receive and not send. Or are you talking about setting authentication? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching and finding no answer: Keith <> asked: | How do I set up Outlook 2003 to recieve mail before sending ...

Outlook needs Outlook Express to work
I've installed my Outlook 2002 on my new Vista PC (I had Xp before). Now when I start Outlook it says "requires Outlook Express 4.01 or greater". I've been looking for Outlook Express to download and install but no joy. No CD came with my new Vista PC. Any ideas, short of buying a more modern Outlook? Vista doesn't actually support Outlook 2002 or older. Outlook Express is part of Internet Explorer but with the advent of Vista, it was switched to Windows Mail. There is no more Outlook Express. You could attempt however to create a profile using workgroup or c...

"The connection to the Exchange server is unavailable. Outlook must be online or connected to complete this action"
I have setup a number of user accounts and the relative mailboxes without any problem. However, since this afternoon, if I try and connect to a newly mailbox through the email accounts wizard I get the following error message: "The connection to the Exchange server is unavailable. Outlook must be online or connected to complete this action". This also occurs when I go to File>Open>Other User's Folder... and I try and lookup an existing account/mailbox that I know I have permission to. I know Outlook is connected to the Exchange server (I can ping, send and receive emails) ...

Outlook "Ruler" won't go away
I don't know how I turned this on so I don't know how to turn it off. It splits my emails so that I can only type so far over before it kicks me back to the left margin and makes me start a new line. Can anyone help me? ...

Outlook 2003
Hello, we have one client pc with Outlook 2003 where the following problem occurs: if a mail is replied from a user created sub folder of the inbox, the reply will not appear in sent mails, but will end up in the same sub folder, sender and recipient appear as identical. The mail goes out properly though, it's just that Outlook sets internally sender = recipient and bounces the reply back to the subfolder in which the original mail is stored. This happens on a Win 2000 machine with SP4 and all updates, the other clients use Outlook 2000 or XP and there is no such problem. There are no ru...

[Exchange 2003] Mail enabled public folder and sender address
I have a Windows 2003 domain with a native mode Exchange 2003 organization; there are some mail enabled public folders. When a user replies to a message in a public folder, the outgoing mail's sender address is the user's one; I want it to be the public folder's one, or at least I'd like the "reply-to" address to be set to the public folder's. How can I accomplish this? Thanks Massimo You would need to grant the user permissions to be able to Send As the public folder. By default, when you reply to a message that is in a PF, the PF is not composing the ...

cant start outlook pst file to large
Hi I hope somebody may be able to help im new to outlook and now I cant start outlook message says cannot open your default email folders pst file its too large as I cannot open outlook I cannot delete old folders See if this helps: -- -Ben- Ben M. Schorr, MVP Roland Schorr & Tower Author: The Lawyer's Guide to Microsoft Outlook 2007: "Ray" <> wrote in message news:B3B824DC-3C9B-4B1B-8EF3-61...

Reminders in Outlook
Since upgrading to Great Plains 9.0, several users are not getting their appointment reminders in Outlook 2003. They all show up at once after rebooting computer. Outlook settings are set appropriately. Any ideas? -- Steve ...

Outlook default to paragraph
To whom ever can help, > > When using Microsoft Outlook, and starting a new E- Mail, The default > format is to "paragraph" which double spaces. Is there anyway to > select under a New Message, Format, Style, "Normal" as the default? > > Thank you in advance > > Dave >-----Original Message----- >To whom ever can help, >> >> When using Microsoft Outlook, and starting a new E- >Mail, The default >> format is to "paragraph" which double spaces. Is there >anyway to >> select unde...

Mail lMerge
Sorry folks. I asked a question and went to the hospital for a while and the question expired. I have an address list in excel 2007 and am using word 2007. In my address list I have a code column which should allow the selection of addresses to put on labels. I used to have a query section what allows for that but I cannot find query any more. can anyone help me? charles Questions here never expire, though it may become difficult to find the answer. The previous post received one reply, from Doug Robbins, as follows: See the article "Mailmerge Labels with Word ...

How To Copy MS Word mailing labels into Excel
I have a word doc that I want to put into Excel. I want to add some more fields to the names and addresses. Is this simple or do I have to learn how to program? Michael Rodriguez City of Grand Prairie Michael, have you tried to copy and paste the data into excel? -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 97 ** remove news from my email address to reply by email ** "Michael Rodriguez" <> wrote in messa...

How can I change 'Normal' Style for Word e-mails to 'Normal (Web)'?
Hi, I'm using Word as my e-mail editor in Outlook 2003 and want to change the default Style for e-mails from 'Normal' to 'Normal (Web)'. The problem is that new e-mails and replies in HTML format use the 'Normal' Microsoft Word 'Style', and this has no gap after paragraphs. The upshot of this is that when sending an e-mail, I have to press return twice to create a gap, but when the recipient views this, their software shows it as four gaps (the extra carriage return I typed + their correctly viewed HTML carriage return after each line). E.g. I type this: ...

Embedded Chart Versus Chart
I've created a class module to capture a Shift+Click on a pivot chart, which then opens the data associated with that point. It works great on pivot charts on their own sheet, but when I use the same code on an embedded chart, it fails (error code -2147417848). Everything seems to work fine, it derives the same row and column values as needed, but the ShowDetail property is unavailable in the embedded charts. Anyone have any insight? james Igoe || || I eventually solved my problem, simply using "On Error Resume Next&...

Office 2003, Outlook (Outlook Today)...
OK, this is driving me nuts. I note that w' 2003 (and XP (2002)?) the default install sets the startup folder to the Inbox. IIRC, one of the earlier Offices installed Outlook to startup w' that "all in one view" - Outlook Today. So just as a wee test - I thought I'd try that for a while, and indeed I found it quite handy to be able to see all pertinent data on the one screen. *However* (and I'm wondering if this is the case with others), I *HAVE* to use my mouse, whenever I switch to the Inbox, or Calendar, or Tasks to get the damn focus onto a 'sujbect&...

Outlook Express 6 w/multiple accounts
I have three accounts set up in Outlook Express 6. Two of them work fine, but when I reply to or forward a message sent to the third address, it uses the second address in the "from" line, so I have to change it manually. This does not happen with the other two. How do I fix this? ...

Mails not appearing in Inbox although on Server and viewable by colleague
Hi all, I have searched the archives and found a few more or less related topics to my problem, but unfortunately none of them helped. Here's my problem: I know that I recieve several mails at a specific time each day. Those mails are sent to a colleague of mine and myself but only he recieves them. My admins looked on the Exchange Server and all say, that they can definetely see these emails in the server logs and that the server delivered them to the right mailbox. If my colleague looks into my mailbox before(!!) I open Outlook, he sees these mails as unread in my inbox. As soon as I op...

OutLook and Notes co-existing.
Outlook and Notes co-existing. Is is possible to mantain Notes as the primary MAPI mail server, but to have Outlook on the same machine, with a separate mail account. I wish to use the automation features of office with the outlook application, to build a solution, but the clients mail is LN. I only wish to use the system to send mails. Does LN support any objects for sending, To, Subject, Body, Attachment, etc which I could use from Access. ? Any reference material, articles etc would help also. Thanks. -- Gerry Mitas Ryemont Abbey, Leixlip, Co. Kildare Phone: 01 6104509 Fax:01 601 ...

Using Visio HTML output within frames
Hi, I want to include visio HTML output in a frame of another html file. Unfortunately it is not working. I understood the problem is in vml_*.htm files. It is due to, the target arrtibute(pointing to _parent) in v:shapetype tag and href attribute (pointing to #) in v:shape tag. These attributes should point to "_top" and "<target-html-file>#" respectively inorder to work. I want to change these options while saving .vsd as web page? I would appreciate if you can help me in this regard. <v:shapetype id="VISSHAPE" target="_parent" coor...

Outlook OOF
The Out of Office Reply will not be sent outside the network. I have exchange 5.5 and have read the faqs but the only fix I found did not work. Here is the number for the fix that I found: Q176161. Thank you for your time and help, Larry 1. Make sure your Exchange server's Internet Mail Service is configured to allow Automatic Replies to the Internet; that's the most common reason it wouldn't work. 2. Reconsider if you really want to use it. You're going to automatically reply to every message you receive; including spam. That's a good way to confirm to the spammer...

Moving Contacts to Outlook Address Book
Need some help. How do I move the names and email addresses from my Contacts list to my Outlook Address Book. When I click on the Outlook Address Book it is empty, but when I click on the Contacts List all the names are there. I am using Outlook 2002. Any help would be appreciated, Thanks Bob Situation normal. What is the problem? The OAB should be empty. Entries reside in the Contacts Folder. -- Russ Valentine [MVP-Outlook] "Bob R" <> wrote in message news:5a2701c42d7e$3de2a7d0$a401280a@phx.gbl... > Need some help. How do I ...