Sending a copy of an incoming email to a network folder

  • Thread starter Thread starter ROBBOLL
  • Start date Start date
R

ROBBOLL

Is there example code to do the following:

You receive an email like: TID(123) This is the subject

The email goes to your inbox as usual, but since it's a "TID(" it moves it
to its matching folder on the network: \\myserver\myemail\TID(123)?

Thanks for any code examples, methods, or suggestions.

RBollinger
 
Since you want it to be saved automatically, you'll need an event
handler. See http://www.codeforexcelandoutlook.com/outlook-vba/stock-event-code/
for starter code.

To save the message, use the MailItem.SaveAs method.

http://msdn.microsoft.com/en-us/library/aa210279(office.11).aspx

Since the folder name is determined by the subject, you'll need to
check the server for a folder with the same content as the subject,
and create the folder if it doesn't exist. i.e.

' check if folder exists
Dim fldr As String
fldr = Dir("\\myserver\myemail\" & MailItem.Subject)
If Len(fldr) = 0 Then
' folder doesn't exist, create it
MkDir "\\myserver\myemail\" & MailItem.Subject
End If

' save the msg to folder here

--JP
 
Back
Top