2009-11-14 11 views
0

Je vais normalement à travers mon tout e-mail et le drapeau pour le suivi et catégoriser pour:Existe-t-il un moyen d'ajouter une catégorie spécifique et de marquer un email dans VBA?

  1. Téléphone Appel
  2. Email
  3. Talk To
  4. réunion d'installation

Est-il possible dans une macro Outlook VBA, je peux (dans une seule macro), à la fois signaler un élément pour suivre et définir l'une des catégories ci-dessus?

+0

Pouvez-vous ajouter la version d'Outlook que vous utilisez. Le modèle d'objet a changé de manière significative entre 2003 et 2007 –

+0

Oui, c'est très facile à faire. Cherchez-vous un bouton, plus un menu déroulant, mis à appeler la macro. –

+0

http://www.dailydoseofexcel.com/archives/2007/03/19/outlook-tags/ Vous pourriez trouver ces commentaires utiles. –

Répondre

1

J'ai trouvé la réponse. .énumérés ci-dessous . . .

Private Sub TagArchived1(category As String) 

    Dim objOutlook As Outlook.Application 
    Dim objInspector As Outlook.Inspector 

    Dim strDateTime As String 

    ' Instantiate an Outlook Application object. 
    Set objOutlook = CreateObject("Outlook.Application") 

    ' The ActiveInspector is the currently open item. 
    Set objExplorer = objOutlook.ActiveExplorer 

    ' Check and see if anything is open. 
    If Not objExplorer Is Nothing Then 
     ' Get the current item. 
     Dim arySelection As Object 
     Set arySelection = objExplorer.Selection 

     For x = 1 To arySelection.Count 
      Dim m As MailItem 
      Set m = arySelection.Item(x) 
      m.Categories = category 
      m.FlagStatus = olFlagMarked 
      m.FlagIcon = 6 
      m.Save 
     Next x 

    Else 
     ' Show error message with only the OK button. 
     MsgBox "No explorer is open", vbOKOnly 
    End If 

    ' Set all objects equal to Nothing to destroy them and 
    ' release the memory and resources they take. 
    Set objOutlook = Nothing 
    Set objExplorer = Nothing 
End Sub 
Questions connexes