View Single Post
  #2  
Old December 7th 06, 07:32 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default How can I save specific emails to d:\email as a .txt file?



You could use a run-a-script-rule that looks for specific words in the
message body and then calls your script. That script could look like this:

Public Sub SaveToFile(Mail as Outlook.MailItem)
Dim Name as String

Name=Mail.Subject
ReplaceCharsForFileName Name, "_"
Mail.SaveAs "d:\" & Name & ".txt",olTXT
End Sub


Private Sub ReplaceCharsForFileName(sName As String, _
sChr As String _
)
' Replaces characters which aren't allowed for file names
sName = Replace(sName, "/", sChr)
sName = Replace(sName, "\", sChr)
sName = Replace(sName, ":", sChr)
sName = Replace(sName, "?", sChr)
sName = Replace(sName, Chr(34), sChr)
sName = Replace(sName, "", sChr)
sName = Replace(sName, "", sChr)
sName = Replace(sName, "|", sChr)
End Sub

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Wed, 6 Dec 2006 07:59:01 -0800 schrieb sthana:

I need to save emails from a particular email address which has "GG123456"

in
the email message as a txt file onto a my local hard disk drive. These

emails
have to be saved as they arrive. I have looked at message rules but cannot
figure out how to save the message as a .txt file. Any help would be
appreciated. Thanks

Ste

Ads