Macro for saving selected mail

R

Raymond

Hi

I've this code to save a selected item. However its doesn't work. I'
getting error 438. Can anyone tell me why

Sub email_save()
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveExplorer.Selection
myItem.SaveAs "C:\Temp\" & myItem.Subject & ".txt", olTXT
myItem.SaveAs "C:\Temp\" & myItem.Subject & ".msg", olMSG
end sub

Greetings Raymon
 
R

Raymond

Here is the answer to my question


VB:
--------------------------------------------------------------------------------
Sub email_save()
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim MsgTxt As String
Pad = "c:\temp"
Number = 0
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
If myOlSel.Count > 1 Then
MsgBox "More The one item seleceted", vbCritical
Exit Sub
Else
For x = 1 To myOlSel.Count
If myOlSel.Item(x).Class = olMail Then
Number = Number + 1
Naam = Mid(myOlSel.Item(x).Subject, 16, 6)
myOlSel.Item(x).SaveAs Pad & Naam & ".txt", olTXT
Else
MsgBox "Only save E-mail", vbInformation, "No E-mail"
Exit Sub
End If
Next x
MsgTxt = "You have saved" & Number & " selected items in " & Pad &
Chr(13) & Chr(13)
MsgBox MsgTxt

End If
End Sub

Raymond
 

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