Welcome to FreeSoftwareServers Confluence Wiki


  • To use the "Rule Wizard" to attach a Macro to a e-mail rule you must do a regedit (I don't do this since it's useless on computers I don't have Admin Priv)
  • You must enable Macros before using the below options or distribute an Add-On
  • Place macro inside "ThisOutlookSession" not a separate Module

Option 1:

  • Can be used to filter by domain or specific sender, edit the 3 options as needed
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)
   If Item.Class = olMail Then
    Dim objMail As Outlook.MailItem
    Dim objAttachment As Attachment
    Set objMail = Item
    Dim objSubjectStr As String, objBodyStr As String, objSenderAddressStr As String
    objSubjectStr = objMail.Subject
    objBodyStr = objMail.Body
    objSenderAddressStr = GetSenderAddrStr(objMail)

    ''''Download Scanner Images''''
    Dim strScannerSender As String, strFolderPath As String, strSubject As String

    strScannerSender = "ALSVN.IT@ALSGlobal.com" '"Bradley.Vanderleeuw@ALSGlobal.com"
    strSubject = "Message from KM_C3320i"
    strFolderPath = "\\NAWHTWS002\Bradley.Vanderleeuw$\MyDocuments\Scanned Docs\"

     If objSenderAddressStr = strScannerSender And objMail.Attachments.Count > 0 And objSubjectStr = strSubject Then
      For Each objAttachment In objMail.Attachments
       objAttachment.SaveAsFile strFolderPath & objAttachment.FileName
      objMail.UnRead = False
     End If
    ''''Download Scanner Images''''
   End If
End Sub
Public Function GetSenderAddrStr(objMail As Outlook.MailItem) As String
 If objMail.SenderEmailType = "SMTP" Then
        GetSenderAddrStr = objMail.SenderEmailAddress
        GetSenderAddrStr = objMail.Sender.GetExchangeUser().PrimarySmtpAddress
 End If
End Function



  • No labels