print email to pdf from specific folder

bqheng

New Member
Joined
Sep 20, 2013
Messages
21
Hi, i took this code off the net and adjusted to my needs. It prints emails to pdf fine, just that it does not include the header of the email (the From, To, Subject part). Can anyone help me with this? also, how do i specify the folder the pdfs are saved to? attached code for reference

VBA Code:
Sub printpdf()
    Dim objDoc, objInspector, myItem, Automation As Object
    Dim outApp As Object, objOutlook As Object, objFolder As Object
    Dim psName As String, pdfName As String

    Set outApp = CreateObject("Outlook.Application")
    Set objOutlook = outApp.GetNamespace("MAPI")
    Set objFolder = objOutlook.GetDefaultFolder(olFolderInbox).Folders("Automation")
    Set myItems = objFolder.Items

For Each myItem In myItems
    Filename = Replace(myItem.Subject, ":", "")
    Set objInspector = myItem.GetInspector
    Set objDoc = objInspector.WordEditor
    objDoc.ExportAsFixedFormat folderPath & Filename & ".pdf", 17
    Set objInspector = Nothing
    Set objDoc = Nothing
Next myItem

End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,214,952
Messages
6,122,458
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top