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年展望》的信息?
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年展望》的信息?
关键参数是:
Const PR_ATTACH_MIME_TAG = "http://schemas.microsoft.com/mapi/proptag/0x370E001E"
Const PR_ATTACH_CONTENT_ID = "http://schemas.microsoft.com/mapi/proptag/0x3712001E"
Const PR_ATTACHMENT_HIDDEN = "http://schemas.microsoft.com/mapi/proptag/0x7FFE000B"
...
Set colAttach = l_Msg.Attachments
For x = 1 To Items.Count
Set l_Attach = colAttach.Add(Items.Item(x))
Set oPA = l_Attach.PropertyAccessor
oPA.SetProperty PR_ATTACH_MIME_TAG, ItemTypes.Item(x)
oPA.SetProperty PR_ATTACH_CONTENT_ID, "item" & x
oPA.SetProperty PR_ATTACHMENT_HIDDEN, True
Next
其他例子:
Option Explicit
Add reference to MS Outlook x.x Object Library
Picture to be added as an attachment and modified src location for each embedded picture.
Private Sub Command1_Click()
Dim oApp As Outlook.Application
Dim oEmail As MailItem
Dim colAttach As Outlook.Attachments
Dim oAttach As Outlook.Attachment
create new Outlook MailItem
Set oApp = CreateObject("Outlook.Application")
Set oEmail = oApp.CreateItem(olMailItem)
add graphic as attachment to Outlook message
change path to graphic as needed
Set colAttach = oEmail.Attachments
Set oAttach = colAttach.Add("D:my documents[color=red]MyPic.jpg[/color]")
oEmail.Close olSave
change the src property to cid:your picture filename
it will be changed to the correct cid when its sent.
oEmail.HTMLBody = "<BODY><FONT face=Arial color=#000080 size=2></FONT>" & _
"<IMG alt= hspace=0 src= [color=red]cid:MyPic.jpg[/color] align=baseline border=0> </BODY>"
oEmail.Save
oEmail.Display fill in the To, Subject, and Send. Or program it in.
Set oEmail = Nothing
Set colAttach = Nothing
Set oAttach = Nothing
Set oApp = Nothing
End Sub
你可以发现:
这是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
In C#, I know that I can overload the constructor for a class by specifying it in the body of the class: public class MyClass() { public MyClass(String s) { ... } } This overrides the default ...
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 ...
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, ...
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 ...
I m using Application run to call several macros in order like this. Sub Run_All_Macros() Application.Run ("Macro_1") Application.Run ("Macro_1") End Sub When I start Run_All_Macros, all the ...
I m using Microsoft Office 2003 and creating a bunch of template documents to standardize some tasks. I asked this on Superuser.com and got no response so I m thinking it s too program-y and hoping I ...
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 ...
I need to ensure a Macro which works on Visio 2003 doesn t cause problems on lower versions of Visio: specifically because I m writing to a property which doesn t exist on lower versions of Visio. ...