Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opening forwarded messages in Outlook via OLE
Message
From
01/02/2000 10:49:20
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00324516
Message ID:
00325588
Views:
33
That's a pretty slick way of doing it, John. Good one.

What you bring up about the speed of lookup and data retrieval in Outlook is a good point. There are some suggestions at MSDN to use Outlook as a data store for Office development. The only thing I can say is "no no no". MS needs to do something about speeding up Outlook.


>The only way I can see to get the senders address is to begin the process of replying to the message. Of course, we don't actually have to send the reply.
>
>
>oReply = oMailitem.Reply
>?oReply.Recipients.Item(1).Address
>
>The other way is to use the info in the sendername property and lookup the entry in contacts. This is seems pretty inefficient to me. So does having to reply to the message. IAC, invoking the reply method works.
>
>
>>Thanks John, this works great. However, I've encountered another hurdle. The main reason for getting to these items is to get the email address. I thought I'd get this by having access to the oMailItem.SenderName property. The problem is the SenderName will often be the person's name instead of their email address. In Outlook you'd right click on the From: John Petersen and choose properties to get a form with the actual email address. I've been looking at the object model at http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/officedev/off2000/oltocobjectmodelapplication.htm but I haven't figured out how to get this form or it's properties programatically. The form looks like it might be a contact item object.
>>
>>Thanks again for your help. I used your ROC program to get my feet wet with Outlook.
>>
>>Regards,
>>
>>E.R. Gilmore
>>
>>>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
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform