K
Kristy
Hi
I use Outlook Redemption to embed graphics into HTML Emails. I have a
problem that I just can't seem to work out how to fix, basically when
I embed a graphic into a new item eveything works fine, however when I
embed an item into an existing item (using GetItemFromID()) the
embedded graphic shows up as an attachment when initially
displayed???? (If I save and close the item or send it and then
reopen it the embedded attachements are hidden in teh attachment list
as expected).
Programmatically closing and reopening the item makes no difference.
I have ensured that PR_ATTACHMENT_HIDDEN is set to 'True' and
PR_ATTACH_CONTENT_ID is set to my graphic. It seems to be some sort
of 'refresh' problem but I am certain that all the items are
deferenced etc?
Any ideas would be much appreciated as I need the embedded attachments
to be hidden when it is created though as it causing confusion with my
customers.
Code sample below:
First, the creation of the existing item....
Private Sub cbbInsertGraphic_Click(ByVal Ctrl As
Office.CommandBarButton, CancelDefault As Boolean)
On Error Resume Next
strItemType = "Insert"
Set golApp = GetObject(, "Outlook.Application")
On Error GoTo 0 'close your error trap
If golApp Is Nothing Then
Err.Clear
'Try and create it
Set golApp = CreateObject("Outlook.Application")
End If
Set objItem = golApp.ActiveInspector.CurrentItem
objItem.Subject = objItem.Subject
objItem.Save
EID2 = objItem.EntryID
objItem.Close olSave
Set objItem = Nothing
Call EmbedGraphic
.....
End Sub
Public Sub EmbedGraphic()
Set golApp = GetObject(, "Outlook.Application")
On Error GoTo 0 'close your error trap
If golApp Is Nothing Then
Err.Clear
'Try and create it
Set golApp = CreateObject("Outlook.Application")
End If
Set objNamespace = Outlook.Application.GetNamespace("MAPI")
objNamespace.Logon "", "", False, False 'Added for Redemption
'create new Outlook MailItem with Letterhead or use existing one
If strItemType = "New" Then
Set MailItem = Outlook.Application.CreateItem(olMailItem)
Else
Set MailItem = objNamespace.GetItemFromID(EID2)
End If
'Add attachment to embed
With MailItem
.Attachments.Add ("C:\Test.jpg")
End With
MailItem.Save
'Set Redemption MailItem
Set sItem = CreateObject("Redemption.SafeMailItem")
sItem.item = MailItem
'add attachment
Set attach = sItem.Attachments(intAttachNumber)
'tell Outlook to hide the paperclip icon
PT_BOOLEAN = 11
PR_HIDE_ATTACH = sItem.GetIDsFromNames("{00062008-0000-0000-C000-000000000046}",
&H8514) Or PT_BOOLEAN
sItem.Fields(PR_HIDE_ATTACH) = True
'content type
attach.Fields(&H370E001E) = "image/jpeg"
'Attachment cid
attach.Fields(&H7FFE000B) = True
attach.Fields(&H3712001E) = strCompanyLogo
MailItem.Subject = MailItem.Subject
sItem.Save
EID = sItem.EntryID
'de-reference the old item
Set attach = Nothing
Set MailItem = Nothing
Set sItem = Nothing
'get 'refreshed' item back again
Set MailItem = objNamespace.GetItemFromID(EID)
MailItem.HTMLBody = "<IMG align=" &
FIRMDetails(strQueryLogoType).Alignment & " border=0 hspace=0
src=cid:" & strCompanyLogo & ">" & "<body bgcolor=#FFFFFF>"
End If
MailItem.Display
' clean up
intNumberOfAttachments = "0"
Set sItem = Nothing
Set MailItem = Nothing
objNamespace.Logoff
Set objNamespace = Nothing
Set golApp = Nothing
End Sub
I use Outlook Redemption to embed graphics into HTML Emails. I have a
problem that I just can't seem to work out how to fix, basically when
I embed a graphic into a new item eveything works fine, however when I
embed an item into an existing item (using GetItemFromID()) the
embedded graphic shows up as an attachment when initially
displayed???? (If I save and close the item or send it and then
reopen it the embedded attachements are hidden in teh attachment list
as expected).
Programmatically closing and reopening the item makes no difference.
I have ensured that PR_ATTACHMENT_HIDDEN is set to 'True' and
PR_ATTACH_CONTENT_ID is set to my graphic. It seems to be some sort
of 'refresh' problem but I am certain that all the items are
deferenced etc?
Any ideas would be much appreciated as I need the embedded attachments
to be hidden when it is created though as it causing confusion with my
customers.
Code sample below:
First, the creation of the existing item....
Private Sub cbbInsertGraphic_Click(ByVal Ctrl As
Office.CommandBarButton, CancelDefault As Boolean)
On Error Resume Next
strItemType = "Insert"
Set golApp = GetObject(, "Outlook.Application")
On Error GoTo 0 'close your error trap
If golApp Is Nothing Then
Err.Clear
'Try and create it
Set golApp = CreateObject("Outlook.Application")
End If
Set objItem = golApp.ActiveInspector.CurrentItem
objItem.Subject = objItem.Subject
objItem.Save
EID2 = objItem.EntryID
objItem.Close olSave
Set objItem = Nothing
Call EmbedGraphic
.....
End Sub
Public Sub EmbedGraphic()
Set golApp = GetObject(, "Outlook.Application")
On Error GoTo 0 'close your error trap
If golApp Is Nothing Then
Err.Clear
'Try and create it
Set golApp = CreateObject("Outlook.Application")
End If
Set objNamespace = Outlook.Application.GetNamespace("MAPI")
objNamespace.Logon "", "", False, False 'Added for Redemption
'create new Outlook MailItem with Letterhead or use existing one
If strItemType = "New" Then
Set MailItem = Outlook.Application.CreateItem(olMailItem)
Else
Set MailItem = objNamespace.GetItemFromID(EID2)
End If
'Add attachment to embed
With MailItem
.Attachments.Add ("C:\Test.jpg")
End With
MailItem.Save
'Set Redemption MailItem
Set sItem = CreateObject("Redemption.SafeMailItem")
sItem.item = MailItem
'add attachment
Set attach = sItem.Attachments(intAttachNumber)
'tell Outlook to hide the paperclip icon
PT_BOOLEAN = 11
PR_HIDE_ATTACH = sItem.GetIDsFromNames("{00062008-0000-0000-C000-000000000046}",
&H8514) Or PT_BOOLEAN
sItem.Fields(PR_HIDE_ATTACH) = True
'content type
attach.Fields(&H370E001E) = "image/jpeg"
'Attachment cid
attach.Fields(&H7FFE000B) = True
attach.Fields(&H3712001E) = strCompanyLogo
MailItem.Subject = MailItem.Subject
sItem.Save
EID = sItem.EntryID
'de-reference the old item
Set attach = Nothing
Set MailItem = Nothing
Set sItem = Nothing
'get 'refreshed' item back again
Set MailItem = objNamespace.GetItemFromID(EID)
MailItem.HTMLBody = "<IMG align=" &
FIRMDetails(strQueryLogoType).Alignment & " border=0 hspace=0
src=cid:" & strCompanyLogo & ">" & "<body bgcolor=#FFFFFF>"
End If
MailItem.Display
' clean up
intNumberOfAttachments = "0"
Set sItem = Nothing
Set MailItem = Nothing
objNamespace.Logoff
Set objNamespace = Nothing
Set golApp = Nothing
End Sub