Consulting

Page 4 of 4 FirstFirst ... 2 3 4
Results 61 to 70 of 70

Thread: Auto Save Attachments from multiple senders

  1. #61
    Trying it now - with a test email and attachment.

  2. #62
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    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.

  3. #63
    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]

  4. #64
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    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.

  5. #65
    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]

  6. #66
    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]

  7. #67
    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]

  8. #68
    BTW - so far I did 4 "self-test" emails and it has not thrown the error. So we will see.


  9. #69
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    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.

  10. #70
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •