I am trying to read all the emails from Outlook mail folder. I was able to access the folder that I want and loop through the messages; however when I debug the application I can notice that huge number of email are retreived as nulls! although I can access
all the information for a little number of emails in the folder.
Regards
Don't forget to click (Mark as Answer) on the post that helped to solve your problem.
Hello mr.aspdotnet, could your post the small but completed codesnipped demonstrating how u extract the mail messages? m> Hi All, m> m> I am trying to read all the emails from Outlook mail folder. I was m> able to access the folder that I want and loop through
the messages; m> however when I debug the application I can notice that huge number of m> email are retreived as nulls! although I can access all the m> information for a little number of emails in the folder. m> m> Regards m>
Actually I am working with Outlook 2003. The problem is that I can access all the message attributes, but for some reason after some emails it starts to read null values. That is the whole object is null not its attributes. For example if I have 200 emails
to read then I will be able to read 100 only and the rest will be read as nulls'.
Regards
Don't forget to click (Mark as Answer) on the post that helped to solve your problem.
mr.aspdotnet
Contributor
2451 Points
426 Posts
Access Outlook from C#
Oct 26, 2007 03:25 PM|LINK
Hi All,
I am trying to read all the emails from Outlook mail folder. I was able to access the folder that I want and loop through the messages; however when I debug the application I can notice that huge number of email are retreived as nulls! although I can access all the information for a little number of emails in the folder.
Regards
shivamG
Member
326 Points
70 Posts
Re: Access Outlook from C#
Oct 26, 2007 04:19 PM|LINK
HI;
The null messages are the messages that have been archived away using compact. When was the last time you did a compact on your outlook?
Regards
Shivam
MCTS - Sql2005
CSM(Certified Scrum master)
mr.aspdotnet
Contributor
2451 Points
426 Posts
Re: Access Outlook from C#
Oct 26, 2007 04:27 PM|LINK
Hi mate,
Actually all the emails that I am reading from outlook are in one folder. None of them is archived
Regards
Michael Nemt...
Participant
1009 Points
193 Posts
MVP
Re: Access Outlook from C#
Oct 29, 2007 10:32 AM|LINK
mr.aspdotnet
Contributor
2451 Points
426 Posts
Re: Access Outlook from C#
Oct 29, 2007 10:42 AM|LINK
Outlook._Application appOutlook = new Outlook.Application();
Outlook.NameSpace outlookNS = appOutlook.GetNamespace("MAPI");
outlookNS.Logon("", null, null, null);
string statInfo;
DateTime today = DateTime.Today;
int eMailsToday = 0;
int eMailsThisMonth = 0;
MAPIFolder inboxFolder = outlookNS.Folders[1].Folders["ErrorsStudy"];
foreach (object item in inboxFolder.Items)
{
Outlook.MailItem mi = item as MailItem;
if (mi != null)
{
if (mi.ReceivedTime.Day == today.Day)
eMailsToday++;
if (mi.ReceivedTime.Month == today.Month)
eMailsThisMonth++;
}
}
statInfo = string.Format("E-mails received today: {0}\n",eMailsToday);
statInfo += string.Format("E-mails received this Month: {0}<br />",eMailsThisMonth);
Response.Write(statInfo);
outlookNS.Logoff();
outlookNS = null;
appOutlook = null;
Regards
Michael Nemt...
Participant
1009 Points
193 Posts
MVP
Re: Access Outlook from C#
Oct 29, 2007 11:17 AM|LINK
/>",eMailsThisMonth); m> m> Response.Write(statInfo); m> m> outlookNS.Logoff(); m> m> outlookNS = null; m> m> appOutlook = null; m> m> Regards m>
mr.aspdotnet
Contributor
2451 Points
426 Posts
Re: Access Outlook from C#
Oct 29, 2007 06:52 PM|LINK
Hi,
Actually I am working with Outlook 2003. The problem is that I can access all the message attributes, but for some reason after some emails it starts to read null values. That is the whole object is null not its attributes. For example if I have 200 emails to read then I will be able to read 100 only and the rest will be read as nulls'.
Regards