English 中文(简体)
如何在2010年展望中的超文本电文中添加一个嵌入图像
原标题:How to add an embedded image to an HTML message in Outlook 2010

I have Office 2003 VBA code that uses the technique described here to embed an image in an HTML message using undocumented MAPI properties and CDO 1.21.

CDO 1.21已不再得到支持,但,其大部分功能现已纳入《2010年展望》目标模型。

我能找到一个样本,利用《2010年展望》目标模型将图像纳入《2010年展望》的信息?

最佳回答
问题回答

这是Dmitry Streblechenko(MVP)的刀切。 它对我来说是很出色的。

Set objOutlook = CreateObject("Outlook.Application")
Set Ns = objOutlook.GetNamespace("MAPI")
Ns.Logon
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Set objOutlookRecip = objOutlookMsg.Recipients.Add("test@dimastr.com")
objOutlookRecip.Type = olTo
objOutlookMsg.Subject = "test"
  add graphic as attachment to Outlook message
Set colAttach = objOutlookMsg.Attachments
Set l_Attach = colAttach.Add("z:Temp81.jpg ")
l_Attach.PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/proptag/0x370E001F", "image/jpeg"   
Change From 0x370eE001E
l_Attach.PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/proptag/0x3712001F", "myident"
 Changed from 0x3712001E
objOutlookMsg.PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8514000B", True
 
Set body format to HTML
objOutlookMsg.BodyFormat = olFormatHTML
objOutlookMsg.HTMLBody = "html tags goes here< img align="
baseline " order="
1 " hspace="
0 " src="
cid: myident " width="
" 600="
" > </img> end html tags"
objOutlookMsg.Save
objOutlookMsg.Send

我发现的方法对我来说是最好的。 我只是与次重挂钩,但发现一些国际用户经历了巨大的滞后,甚至box在方框中。 我转而谈如下,以便把图像放在电子邮件中,并解决了滞后问题,因为文件实际上被放在电子邮件中。

Sub sendKeyMailer()


Dim emlMsg As Object
    Set emlMsg = CreateObject("CDO.Message")

    strBody = "<html> yadda yadda tricks are for kids. <br><br>"
    strBody = strBody & "<img src=""cid:myimage.jpg""><BR><BR>"
    strBody = strBody & "but tricks make the world go round.</html>"

    emlMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    emlMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "<<yourserver>>"
    emlMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    emlMsg.Configuration.Fields.Update
    
    emlMsg.AddRelatedBodyPart "C:	empThe Big Eskimo Roll.jpg", "myimage.jpg", cdoRefTypeId
    emlMsg.Fields.Item("urn:schemas:mailheader:Content-ID") = "<myimage.jpg>"
    emlMsg.Fields.Update
        
    
    With emlMsg
            .To = "allthepeople@yourcompany.com"
            .From = "aGrpLst@yourcompany.com"
            .Subject = "Humpty dumpty had a great fall"     I have kids....;^D.....
            .HTMLbody = strBody
             .AddAttachment "C:	empThe Big Eskimo Roll.jpg"
            .Send
    End With

    Set emlMsg = Nothing

End Sub




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签