Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opening forwarded messages in Outlook via OLE
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00324516
Message ID:
00324771
Views:
33
If you got as far as accessing the attachment, I will start from there....

*/ Save the attachment as a file.
oMailItem.Attachments.item(1).saveasfile(oMailItem.Attachments.item(1).FileName)

Now, here is where it gets tricky.. How the heck do you open the MSG file? Believe it or not, it is not as simple as creating a mail item, and then invoking an Open Method. There is no Open Method anywhere in the Outlook Object Model.. < s >.

Anyway, once you have the attachment saved, you can then use IE to open the MSG file:

oie = createobject("internetexplorer.application")
oie.navigate(oMailItem.Attachments.item(1).FileName)
*/ We don't need IE anymore...
oie.quit


This will cause the saved attachment to become the active element in Outlook. Outlook has a neat method called ActiveInspector, which returns an Inspector Object. The Inspector Object in turn,has an object called currentitem, which is the mail item we just opened.

Assuming your outlook instance is called oOutlookObject, the following code will allow you to peek inside the mail item:

oInspector = oOutlookObject.ActiveInspector
oMailItem = oInspector.CurrentItem
?oMailItem.Subject
?oMailItem.Body

Finally, when you are ready to close the item down, you can use this code:

oMailItem.Close(0)


Here is some sample code that starts the process and takes it to the end:
oInspector = Null
oOutLookObject = CreateObject("Outlook.Application")
oIE = Createobject("internetexplorer.Application")
olNameSpace = oOutlookObject.GetNameSpace("MAPI")
oFolder = olNameSpace.Folders("Personal Folders").Folders("test")
oItem = oFolder.Items(1)
If File("c:\temp\"+oItem.Attachments.item(1).FileName)
   Erase ("c:\temp\"+oItem.Attachments.item(1).FileName)
Endif
oItem.Attachments.item(1).saveasfile("c:\temp\"+oItem.Attachments.item(1).FileName)
oIE.Navigate("c:\temp\"+oItem.Attachments.item(1).FileName)
Do While .T.
   oInspector = oOutlookObject.ActiveInspector
   If !IsNull(oInspector)
      Exit
   Endif   
EndDo
oMailItem = oInspector.CurrentItem
?oMailItem.Subject
?oMailItem.Body
oMailItem.Close(0)
Let me know how things work out!!





>When a email message gets forwarded in Outlook it is received as an attachment. Is there a way to get mail item properties from a forwarded message? I can access the attachment via OLE but I can't get any of the mail item propeties.
>
>
>TIA,
>
>E.R. Gilmore
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform