WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE and Outlook
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Read Open Active Outlook Message

 Keywords:  Read Currently Open Active Outlook Message Email Inspector ActiveInspector

Question:

I'm not familiar with OLE but I'd like to make a list of the attachments in an open Outlook message. Could someone help me get started?

Answer:

The ActiveInspector method returns the topmost Inspector object on the desktop. If no inspector is active, returns 0. Use this method to access the Inspector object that the user is most likely to be viewing.

For Example:

objApp = ObjectCreate("Outlook.Application")
objInspector = objApp.ActiveInspector
olMail = 43
;Check for active inspector
If objInspector!=0
   objCurrItem = objInspector.CurrentItem
   class = objCurrItem.Class
   ;Check if message item
   If objCurrItem.Class == olMail
      Sender = objCurrItem.SenderName
      Body = objCurrItem.Body
      objAttachments =  objCurrItem.Attachments
      count = objAttachments.Count
      For i = 1 To count
       objAttach = objAttachments.Item(i)
       filename = objAttach.FileName
       Pause('Attachment ': i, filename)
      Next

      Message(Sender,Body)
   Else
      Message("Error","Not a Mail Item")
   EndIf

Else
   Message("Error","No Active Inspector")
EndIf
objInspector = 0
objApp = 0
Exit


Article ID:   W18094
Filename:   Read Open Active Outlook Message.txt
File Created: 2010:06:21:10:26:58
Last Updated: 2010:06:21:10:26:58