У меня есть этот код в Outlook VBA ThisOutlookSession, он не выдает никакой ошибки, но не загружает вложения. Любая идея
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 strSenderDomain = "gmail.com" Then
If strSenderAddress = "vs@gmail.com" Then
If objMail.Attachments.Count > 0 Then
For Each objAttachment In objMail.Attachments
strFolderPath = "E:\Cisco - Qutar\Performance Report Automation\"
strFileName = objMail.Subject & " " & Chr(45) & " " & objAttachment.FileName
objAttachment.SaveAsFile strFolderPath & strFileName
Next
End If
End If
End If
End If
End Sub
Обновлено сейчас