Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   How can I save specific emails to d:\email as a .txt file? (http://www.outlookbanter.com/outlook-vba/34659-how-can-i-save-specific.html)

sthana December 6th 06 04:59 PM

How can I save specific emails to d:\email as a .txt file?
 
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

Michael Bauer [MVP - Outlook] December 7th 06 07:32 AM

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



All times are GMT +1. The time now is 09:13 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com