我正在使用此代码
Public Sub ProcessarAnexo(Email As MailItem)
Dim DiretorioAnexos As String
Dim MailID As String
Dim Mail As Outlook.MailItem
Dim objOLmail As Object
这是我需要保存附件的文件夹
DiretorioAnexos = "C:\Separados\AlamoLogistica\"
MailID = Email.EntryID
Set Mail = Application.Session.GetItemFromID(MailID)
在此部分中,代码会从邮件中分离附件
For Each anexo In Mail.Attachments
If Right(anexo.FileName, 3) = "xml" Then
anexo.SaveAsFile DiretorioAnexos & anexo.FileName
End If
If Right(anexo.FileName, 3) = "zip" Then
anexo.SaveAsFile DiretorioAnexos & anexo.FileName
End If
Next
Set Mail = Nothing
此代码有效,或许我需要通过电子邮件adreess分隔附件
我写了这个:
Dim ns As Outlook.NameSpace
Dim Inbox As Outlook.MAPIFolder
Dim appOl As New Outlook.Application
Dim DiretorioAnexos As String
Dim MailID As String
Dim Mail As Outlook.MailItem
Dim objOLmail As Object
此处代码必须将“Caixa de Entrada”或“收件箱”分配给Mapifolder收件箱
Set ns = appOl.GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
For Each objOLmail In Inbox.Items
如果来自longfe@ifdcontroladoria.com.br的邮件必须转到文件夹“”C:\ Separados \ AlamoLogistica \“”
If InStr(objOLmail.SenderEmailAddress, "longfe@ifdcontroladoria.com.br") >= 0 Then
DiretorioAnexos = "C:\Separados\AlamoLogistica\"
MailID = Email.EntryID
Set Mail = Application.Session.GetItemFromID(MailID)
For Each anexo In Mail.Attachments
If Right(anexo.FileName, 3) = "xml" Then
anexo.SaveAsFile DiretorioAnexos & anexo.FileName
End If
If Right(anexo.FileName, 3) = "zip" Then
anexo.SaveAsFile DiretorioAnexos & anexo.FileName
End If
Next
End If
Next
Set Mail = Nothing
但代码不起作用我做错了????
答案 0 :(得分:1)
SenderEmailAddress
字段可能产生与this question中的输出类似的内容。
尝试使用objOLmail.SenderEmailAddress
objOLmail.Sender.GetExchangeUser().PrimarySmtpAddress