A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Read Outlook Mail Item From Value



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 5th 09, 03:49 PM posted to microsoft.public.outlook.program_vba
andjbird via OfficeKB.com
external usenet poster
 
Posts: 3
Default Read Outlook Mail Item From Value

I want to be able to read an Outlook Inbox mail message 'From' value to
enable me to automatically move the Inbox mail item into a corresponding
folder in the 'Personal Folder' folder. Also, if the corresponding folder
does not exist, create a folder using the senders name.

I have the following script that iterates through the items in the 'Inbox',
but I am unable to identify the senders name from the mail items as used in
the script. Does anyone have a method which I can use to proceed with this.

Private Sub Application_NewMail()

Dim InputFolder As Outlook.MAPIFolder
Set InputFolder = Application.GetNamespace("MAPI").GetDefaultFolder
(olFolderInbox)
Dim intCount As Integer

For intCount = 1 To InputFolder.Items.Count
'If InputFolder.Items(intCount).UnRead = True Then 'Read out the
unread mail in Inbox.

If InputFolder.Items(intCount).UnRead = True Then

MsgBox InputFolder.Items(intCount).Subject
MsgBox InputFolder.Items(intCount).Body

End If

Next intCount

End Sub

e.g. I have tried to reference the senders name using 'InputFolder.Items
(intCount).From', but the system does not recognise this. Also, for some
Inbox items the Debug displays that the 'InputFolder.Items(intCount)' object
does not contain any variables.

I look forward to receiving any suggestions.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...g-vba/200905/1

Ads
  #2  
Old May 5th 09, 04:27 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Read Outlook Mail Item From Value

The object browser (F2 in VBA) is your friend. If you used it, you'd soon
see that the MailItem object has no From property, but does have a
SenderName property.

This would be a better For ... Next loop to gather information about items
in a folder:

For Each itm in InputFolder.Items
' do stuff with the itm
If itm.UnRead = True Then
etc.
End If

However, if you plan to move or delete items, then you need to use a
down-counting loop.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"andjbird via OfficeKB.com" u5428@uwe wrote in message
news:95a0af3783ab0@uwe...
I want to be able to read an Outlook Inbox mail message 'From' value to
enable me to automatically move the Inbox mail item into a corresponding
folder in the 'Personal Folder' folder. Also, if the corresponding folder
does not exist, create a folder using the senders name.

I have the following script that iterates through the items in the
'Inbox',
but I am unable to identify the senders name from the mail items as used
in
the script. Does anyone have a method which I can use to proceed with
this.

Private Sub Application_NewMail()

Dim InputFolder As Outlook.MAPIFolder
Set InputFolder = Application.GetNamespace("MAPI").GetDefaultFolder
(olFolderInbox)
Dim intCount As Integer

For intCount = 1 To InputFolder.Items.Count
'If InputFolder.Items(intCount).UnRead = True Then 'Read out the
unread mail in Inbox.

If InputFolder.Items(intCount).UnRead = True Then

MsgBox InputFolder.Items(intCount).Subject
MsgBox InputFolder.Items(intCount).Body

End If

Next intCount

End Sub

e.g. I have tried to reference the senders name using 'InputFolder.Items
(intCount).From', but the system does not recognise this. Also, for some
Inbox items the Debug displays that the 'InputFolder.Items(intCount)'
object
does not contain any variables.

I look forward to receiving any suggestions.



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Applying Outlook rules only after mail item is read. Dinesh Patil Outlook and VBA 1 March 5th 08 02:12 PM
Making email item 'Read' programmatically Dinesh Patil Outlook and VBA 1 March 3rd 08 02:17 PM
Read contents of Note inserted in Outlook Contact Item Body JPL Outlook and VBA 4 June 5th 06 08:19 PM
Calendar is showing 1 unread item, but all items are read KNM101 Outlook - Calandaring 7 May 30th 06 03:40 PM
How do I modify Delete button to also mark item as read? [email protected] Outlook and VBA 1 April 24th 06 06:14 AM


All times are GMT +1. The time now is 04:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.