Trying it now - with a test email and attachment.
Trying it now - with a test email and attachment.
try it with an email that doesn't have an attachment too since that is what caused your error.
-----------------------------------------
The more you learn about something the more you know you have much to learn.
Ok I had one of my Senders send me an email with attachment. The code stopped at the highlighted line:
Error - Path does not exist (but yes it does)
[vba]
ElseIf (Msg.Sender = "Sender, Jane") And _
(Msg.Subject = "WV UMTS Backlog") And _
(Msg.Attachments.Count >= 1) Then
attPath = "I:\UTMS_WV\Process\"
myAttachments.Item(1).SaveAsFile attPath & Att
Call Mail_Working
Msg.UnRead = False
'Msg.Move olDestFldr
[/vba]
Are you sure the drive isn't mapped differently or maybe the path is spelled slightly differently? Is there any special permissions on the folder?
-----------------------------------------
The more you learn about something the more you know you have much to learn.
Ok I had one of my known Sender send an email with attachment (meets criteria).
I received msg box: "Cannot save the attachment. Path does not exist. Verify the path is correct."
[vba]
attPath = "I:\Mail\"
[/vba]
No path not changed. Remember this worked as it should with the exception of throwing the error when an unmatched email arrived.
Here are the on;y changes that i have made:
1). get rid of myAttachments.Item(1).SaveAsFile attPath & Att
then
2). Changed
[vba]
If TypeName(Item) = "MailItem" Then
Set Msg = Item
' save attachment
Set myAttachments = Item.Attachments
Att = myAttachments.Item(1).DisplayName
myAttachments.Item(1).SaveAsFile attPath & Att
[/vba]
To this
[vba]
If TypeName(Item) = "MailItem" And Item.Attachments.Count > 0 Then
Set Msg = Item
Set myAttachments = Item.Attachments
[/vba]
I think you were on to something with adding the count. I changed everything back to what I had working and added the count you mentioned.
Will see how that goes.
[vba]
If TypeName(Item) = "MailItem" And _
Item.Attachments.Count > 0 Then
Set Msg = Item
Set myAttachments = Item.Attachments
Att = myAttachments.Item(1).DisplayName
myAttachments.Item(1).SaveAsFile attPath & Att
[/vba]
BTW - so far I did 4 "self-test" emails and it has not thrown the error. So we will see.
You don't want
[VBA] myAttachments.Item(1).SaveAsFile attPath & Att [/VBA]
before your second if statement.
If you copy my code from post 60 exactly and just adjust the paths, senders and subjects you shouldn't have any problems. I'm suprised its not failing on that line since you haven't defined the attpath unless you defined that before. If you have then your probably saving it in 2 locations.
-----------------------------------------
The more you learn about something the more you know you have much to learn.
Hmm - ok I will revise in the morning when I get in. The path is not defined anywhere other than in the individual IF statements, I will check to see if the files have been saving other locations as well. Thanks!