Save incoming Email as .html file with name of subject line

M

Matt

Hello all!

I am using the below code to save all incoming emails as an XML file. The
problem is that a new incoming email overwrites the previous one. What I'd
like to do is name the XML file as the subject line of the incoming email.
Would someone please help me?

Sub saveemail(myItem As Outlook.MailItem)
myItem.SaveAs "c:\mail\test.XML", olXML
End Sub

Matt
 
M

Matt

Never mind...... I was able to do it. In case anyone else need to know how:

Sub saveemail(myItem As Outlook.MailItem)
myItem.SaveAs "c:\mail\" & myItem.Subject & ".xml", olXML
End Sub

Thanks All!
 
C

Chris

Matt:

You might want to add either ReceivedTime(Emails) or CreationTime(Reports)

Yoru code would look like:
myItem.SaveAs "c:\mail\" & myItem.Subject & "_" & myItem.ReceivedTime &
".xml", olXML

As I have discovered, you may need to scrub the subject and time of any
illegal characters such as "/", ":", or "*" etc.

Chris
 
M

Matt

Hey Chris,

Good Idea!

Thanks

Matt

Chris said:
Matt:

You might want to add either ReceivedTime(Emails) or CreationTime(Reports)

Yoru code would look like:
myItem.SaveAs "c:\mail\" & myItem.Subject & "_" & myItem.ReceivedTime &
".xml", olXML

As I have discovered, you may need to scrub the subject and time of any
illegal characters such as "/", ":", or "*" etc.

Chris
 

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