title: How to automatically save attachment from specific sender?
body: <p>I would like to automatically save attachments from a specific sender in a predetermined folder.</p>
  
  <pre><code>Public WithEvents objInboxItems As Outlook.Items
  
  Private Sub Application_Startup()
     Set objInboxItems = Session.GetDefaultFolder(olFolderInbox).Items
  End Sub
  
  Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
     Dim objMail As Outlook.MailItem
     Dim strSenderAddress As String
     Dim strSenderDomain As String
     Dim objAttachment As Attachment
     Dim strFolderPath As String
     Dim strFileName As String
  
     If Item.Class = olMail Then
        Set objMail = Item
  
        'Get sender domain
        strSenderAddress = objMail.SenderEmailAddress
        'strSenderDomain = Right(strSenderAddress, Len(strSenderAddress) - InStr(strSenderAddress, "@"))
  
        'Change to the specific domain as per your needs
        If strSenderAddress = "Da.Te@union.de" Then
           If objMail.Attachments.Count &gt; 0 Then
              For Each objAttachment In objMail.Attachments
                  'Change the folder path where you want to save attachments
                  strFolderPath = "U:\Test"
                  strFileName = objMail.Subject &amp; " " &amp; Chr(45) &amp; " " &amp; objAttachment.FileName
                  objAttachment.SaveAsFile strFolderPath &amp; strFileName
              Next
           End If
        End If
     End If
  End Sub
  </code></pre>
  
  <p>This code is from <a href="https://www.datanumen.com/blogs/how-to-auto-save-all-attachments-from-senders-in-a-specific-domain-via-outlook-vba/" rel="nofollow noreferrer">here</a>, with minor modifications.</p>