Hi All,

I'm trying to save an incoming email as a .txt document but I'm having some trouble with the VBA.

My procedure is as follows:

Sub ConvertToPlainAndSaveAs(Mymail As MailItem)
    Dim strID As String
    Dim objMail As Outlook.MailItem

    strID = Mymail.EntryID
    Set objMail = Application.Session.GetItemFromID(strID)
    objMail.BodyFormat = olFormatPlain

    objMail.SaveAs "C:\Users\Me\Documents\path\to\Test.txt", olTXT

    Set objMail = Nothing
End Sub

It isn't saving the email though.

Where am I going wrong?

Thanks in advance.

Turns out it wasn't the procedure that was the problem but the security settings on macros. Don't know why that happened as it worked fine on Friday and I haven't changed a thing. Apparently that's how microsoft rolls. F@*k You, Microsoft!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.