Jump to content

Getting .MSG attachments from Outlook into EN using VBA


Remco Smit

Recommended Posts

Hi,

 

Not being a real developper, I do know my way arround in VBA. The 'regular' EN Support guys couldn't help me and pointed me in this direction.

 

What I'd like to achieve is this:

Get emails from Outlook (2010/2013) into Evernote both as readable text (default behaviour) AND as attached .MSG file in 1 note. The last part fails as EN reads the MSG file and puts the content in the Note.

 

Why I want to do this? Because I want to be able to quickly read email messages (without opening the attachment) AND reply to or forward that message from EN. If this works, I can delete the mail message from outlook, keeping my mailbox empty. EN is then my single source of message that are actionable for me.

 

(see attachment).

 

This is what I have in VBA so far:

 

  1. Save an email to a temp location on disk as .msg
  2. Attach that file to the original email messsage or to the Forward mail dialog window (this is drawn in above picture).
    • now the mail it attached to itself, containing the original header. Allows me to double-click from EN, open Outlook and reply/forward the original mail.

And here it ends.

 

I have tried to:

  • forward to my evernote address. Doesn't work: .msg attachment is read by EN and put in the note as text. Attachment gone.
  • forward 'as attachment' (outlook option) to my evernote address. Doesn't work: .msg attachment is read by EN and put in the note as text. Attachment gone.
  • save the mail as .msg in the EN importfolder. Doesn't work: .msg attachment is read by EN and put in the note as text. Attachment gone.

Is there a way to bypass that annoying function of EN that reads MSG files and converts it to text? 

 

Thanks

Remco Smit

The Netherlands.

post-102662-0-65715500-1372840842_thumb.

Link to comment
  • Level 5*

There's an Outlook add-in that will clip your emails to Evernote as text.  If you also drag and drop the message to your (Windows) desktop and then into the same note,  you have both text and msg files.  Dunno any way to do that via VB script,  but AutoHotKey might work..

Link to comment
  • 1 year later...

After looking at the new Cloud SDK API and determining I didn't want to be online to make this this, I managed to do this via VBA calling out to the enscript.exe. Here's a code snippet...

 

          Dim strMsgFileName As String
                Dim strTxtFileName As String
                Dim strExeCall As String
                
                strMsgFileName = strSubFolder & strSubject & ".msg"
                strTxtFileName = strSubFolder & strSubject & ".txt"
                
                strExeCall = """c:\program files (x86)\evernote\evernote\enscript.exe"" createNote /s """ & txtFileName & """ /i """ & strAction & """ /a """ & msgFileName & """"

                objItem.SaveAs strMsgFileName, olMSG
                objItem.SaveAs strTxtFileName, olTXT
                objItem.Categories = "Sent to Evernote"
                objItem.Save
                    
                Call Shell(strExeCall, vbHide)

 

 

Some notes...strAction is captured earlier using InputBox, and I'm using the standard Outlook object model (getting selected item as objItem) to save as txt and MSG format. The nice thing about this is that you can have an action title different from the email subject! I also update the Category on the email so I know I've already processed this email.

Link to comment
  • 3 months later...
  • 5 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...