Saving mail (.msg) after clicking context menu button

D

davemode

Hello everybody!!

I created a new button in the context menu
(http://www.outlookcode.com/codedetail.aspx?id=314) and so I wanted to
save the selected mail to the harddisk.

I found some code snipes like that:

' ### first find the selected item ###
Dim objApp As Application
Dim objItem As Object
Dim objSelection As Selection
Dim intMaxItems As Integer
intMaxItems = 5
Set objApp = CreateObject("Outlook.Application")
Set objSelection = objApp.ActiveExplorer.Selection
Select Case objSelection.Count
Case 0
MsgBox "No items were selected"
Case Is > intMaxItems
MsgBox "Too many items were selected"
Case Else
'objSelection.Item
End Select


To save a mail I should use the mailItem-Object, but this only shows
how to save an new mail:

Dim myItem As Outlook.Inspector
Dim objItem As Object
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector
If Not TypeName(myItem) = "Nothing" Then
Set objItem = myItem.CurrentItem
strname = objItem.Subject
'Prompt the user for confirmation
objItem.SaveAs "C:\" & strname & ".txt", olTXT
End If
Else
MsgBox "There is no current active inspector."
End If


Now I want to merge these two code snipets, but I have no idea how to
manage it!

Has anybody an idea how I can save the selected mail by right-Clicking
in the context-menu?

Thank you for your help!!!

Walter.
 
D

Dmitry Streblechenko

Loop through all entries in the Selection collection (1 through
Selection.Count) and for each item (Selection.Item(index)), call SaveAs().

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top