2012-11-26 4 views
0

I m en utilisant ce codeIdentifiez l'adresse e-mail dans Outlook 2010

 Public Sub ProcessarAnexo(Email As MailItem) 

     Dim DiretorioAnexos As String 
     Dim MailID As String 
     Dim Mail As Outlook.MailItem 
     Dim objOLmail As Object 

Ceci est le dossier dans lequel je dois enregistrer les pièces jointes

 DiretorioAnexos = "C:\Separados\AlamoLogistica\" 
     MailID = Email.EntryID 
     Set Mail = Application.Session.GetItemFromID(MailID) 

Dans cette partie du code Séparés l'attachement de la mail de

 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 

Ce code fonctionne, je dois peut-être separé les pièces jointes par l'e-mail adreess

i ont écrire ceci:

  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 

Ici, le code doit attribuer "Caixa de Entrada" ou "Boîte de réception" à la boîte de réception MAPIFolder

 Set ns = appOl.GetNamespace("MAPI") 
    Set Inbox = ns.GetDefaultFolder(olFolderInbox) 

    For Each objOLmail In Inbox.Items 

ici si le courrier de longfe @ ifdcontroladoria. com.br doit aller dans le dossier "" C: \ Separados \ AlamoLogistica \ ""

If InStr(objOLmail.SenderEmailAddress, "[email protected]") >= 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 

mais le code ne fonctionnent pas ce im faire mal ????

Répondre

1

Il est possible que le champ SenderEmailAddress produise quelque chose de similaire à la sortie en this question. Essayez de remplacer objOLmail.SenderEmailAddress dans votre instruction If par objOLmail.Sender.GetExchangeUser().PrimarySmtpAddress