J
Jado
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
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