Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / October 2004

Tip: Looking for answers? Try searching our database.

Redemption - Embed Images using separate Function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jado - 29 Oct 2004 12:00 GMT
Hi

I was pointed to the redemption site for some code used to embed images into
an email created using .HTMLBody

this code shows how to embed a single image into an email.

i've been trying to split this code, so that adding more than 1 image is an
easy and clean task.

i'm not an advanced programmer, and have not mannaged to get this to work.

i was wondering if someone could help!

The 3rd Function is the one from the Redemption site. I have not made any
changes to this function so you can see how it works on it's own.

Thanks

Jado

---------------------------------------------------
Function CreatEmail()
Dim SafeItem, oItem
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance
of Redemption.SafeMailItem
Set oItem = Application.CreateItem(0) 'Create a new message
SafeItem.Item = oItem 'set Item property

'This is the part i'm talking about
SafeItem.HtmlBody = BuildHTML

SafeItem.Display

Set SafeItem = Nothing

End Function
-------------------------------------------------
Function BuildHTML() As String

 Dim sHTML As String
 sHTML = sHTML & "<table width=""50%"" border=""0"" align=""center""
cellpadding=""0"">"
 sHTML = sHTML & "<tr>"

 'I want to Embed an Image here using a function
EmbedHTMLImage("c:\test1.jpg")??

 sHTML = sHTML & "<td><img src=""file:///C|/test1.jpg"" width=""152""
height=""128"" align=""middle""></td>"
 sHTML = sHTML & "</tr>"
 sHTML = sHTML & "<tr>"

 'I want to Embed an Image here using a function
EmbedHTMLImage("c:\test2.jpg")??

 sHTML = sHTML & "<td><img src=""file:///C|/test2.jpg"" width=""781""
height=""266""></td>"
 sHTML = sHTML & "</tr>"
 sHTML = sHTML & "<tr>"

 'I want to Embed an Image here using a function
EmbedHTMLImage("c:\test3.jpg")??

 sHTML = sHTML & "<td><img src=""file:///C|/test3.jpg"" width=""283""
height=""212""></td>"
 sHTML = sHTML & "</tr>"
 sHTML = sHTML & "</table>"

BuildHTML = sHTML

End Function
--------------------------------------------------
Function EmbedHTMLImage()
'This is how you embed images on the network into dynamically created HTML
Emails
' you must have redemption installed on each pc that uses it.

Set DraftsFolder = Application.Session.GetDefaultFolder(16)
Set MailItem = DraftsFolder.Items.Add
Set sitem = CreateObject("Redemption.SafeMailItem")
sitem.Item = MailItem
'tell Outlook to hide the paperclip icon
'this is a named prop, so we must call GetIDsFromNames() first!
PT_BOOLEAN = 11
PR_HIDE_ATTACH =
sitem.GetIDsFromNames("{00062008-0000-0000-C000-000000000046}", &H8514) Or
PT_BOOLEAN
sitem.Fields(PR_HIDE_ATTACH) = True
'add attachment
Set Attach = sitem.Attachments.Add("c:\test.jpg")
'content type
Attach.Fields(&H370E001E) = "image/jpeg"
'Attachment cid
Attach.Fields(&H3712001E) = "myident"
sitem.HtmlBody = "<b>test image:</b><IMG align=baseline border=0 hspace=0
src=cid:myident>"
sitem.Save
'IMPORTANT - dereference everything
Set Attach = Nothing
Set sitem = Nothing
Set MailItem = Nothing
Set DraftsFolder = Nothing
End Function
Dmitry Streblechenko \(MVP\) - 29 Oct 2004 22:18 GMT
You simply need to make sure that you use a unique cid for each attachment
and call EmbedHTMLImage for each image.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

> Hi
>
[quoted text clipped - 100 lines]
> Set DraftsFolder = Nothing
> End Function
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.