Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TO address in outlook

Status
Not open for further replies.

SimonFinn

Programmer
Mar 13, 2003
130
GB
Hi

I am currently writing a program to update an access database when emails that are sent bounce.

I have this code which i have developed to get the To Address from the bounced email which has been forwarded to a nominated folder by our exchange server.

On the code "strSubject = Mailobject.To" i get the error Object Does not support this property or method. If i change it to MailObject.Subject it returns the subject (as it is the default property it also gets the subject from just MailObject). I cannot find the property which will retrieve the TO address.

Thanks Si


Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetFolderFromID("000000001A447390AA6611CD9BC800AA002FC45A0300FF6C9755E895FE4D94EA24DA77841BA4000000001CAF0000")


Set InboxItems = Inbox.Items
Dim strSubject As String
For Each Mailobject In InboxItems
'on error resume next
strSubject = Mailobject.To
MsgBox strSubject
Next

Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
 
When you get the error and go into debug mode, try (in the immediate window),

?typename(mailobject)

If it's a MailItem, your code should work just fine, but since folders can contain different types of items as well, maybe the item that's found is of a different type.


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top