Hi all,
In Outlook v11 there is an issue I have seen many posts around the internet on. If you print an email with an attachement, it does not list the attachments on the print. It does this in Outlook Express. I do not believe there to be an option to make this available so I've been looking for a macro to do the magic.
This macro ideally would, on print, insert the name of all attachments to the email below the normal headings... see below...
NAME______________
From: yadaa yaddy
Sent: yadaa yaddy
To: yadaa yaddy
Subject: yadaa yaddy
Attachment: FILE.name <<<
BODY
I looked around, and I found the following code, but it does nothing for me. Please advise.
Thanks
MK
Private Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
' instantiate objects declared WithEvents
Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing
End Sub
Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
Call AppendNames(Item)
End Sub
Private Sub AppendNames(ByVal objItem As Object)
Dim objAttach As Attachment
Dim strBody As String
Dim strAttach As String
Dim strCRLF As String
Dim intFormat As Integer
strAttach = ""
'Don't process if it's not an e-mail
If objItem.MessageClass <> "IPM.Note" Then Exit Sub
'Don't process if there aren't attachments
If objItem.Attachments.Count = 0 Then Exit Sub
If objItem.HTMLBody <> vbNullString Then
strCRLF = "
"
Else
strCRLF = vbCrLf
End If
'Build the names into a string
strAttach = strCRLF & strCRLF
For Each objAttach In objItem.Attachments
strAttach = strAttach & "Attached File: " & objAttach.DisplayName & strCRLF
Next
'Insert the names into the body
If objItem.HTMLBody <> vbNullString Then
strBody = objItem.HTMLBody
strBody = Replace(strBody, "</BODY>", strAttach & "</BODY>")
objItem.HTMLBody = strBody
Else
strBody = objItem.Body
strBody = strBody & strAttach
objItem.Body = strBody
End If
objItem.Save
End Sub
In Outlook v11 there is an issue I have seen many posts around the internet on. If you print an email with an attachement, it does not list the attachments on the print. It does this in Outlook Express. I do not believe there to be an option to make this available so I've been looking for a macro to do the magic.
This macro ideally would, on print, insert the name of all attachments to the email below the normal headings... see below...
NAME______________
From: yadaa yaddy
Sent: yadaa yaddy
To: yadaa yaddy
Subject: yadaa yaddy
Attachment: FILE.name <<<
BODY
I looked around, and I found the following code, but it does nothing for me. Please advise.
Thanks
MK
Private Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
' instantiate objects declared WithEvents
Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing
End Sub
Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
Call AppendNames(Item)
End Sub
Private Sub AppendNames(ByVal objItem As Object)
Dim objAttach As Attachment
Dim strBody As String
Dim strAttach As String
Dim strCRLF As String
Dim intFormat As Integer
strAttach = ""
'Don't process if it's not an e-mail
If objItem.MessageClass <> "IPM.Note" Then Exit Sub
'Don't process if there aren't attachments
If objItem.Attachments.Count = 0 Then Exit Sub
If objItem.HTMLBody <> vbNullString Then
strCRLF = "
"
Else
strCRLF = vbCrLf
End If
'Build the names into a string
strAttach = strCRLF & strCRLF
For Each objAttach In objItem.Attachments
strAttach = strAttach & "Attached File: " & objAttach.DisplayName & strCRLF
Next
'Insert the names into the body
If objItem.HTMLBody <> vbNullString Then
strBody = objItem.HTMLBody
strBody = Replace(strBody, "</BODY>", strAttach & "</BODY>")
objItem.HTMLBody = strBody
Else
strBody = objItem.Body
strBody = strBody & strAttach
objItem.Body = strBody
End If
objItem.Save
End Sub