msoutlook.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

access mail from public folder

 
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Programs Add-Ins
Author Message
mithilesh



Joined: 27 Jan 2008
Posts: 8

PostPosted: Tue Feb 26, 2008 3:25 am    Post subject: access mail from public folder Reply with quote

Hi,

I'm trying to use outlook 2003 and access mail from public folder.

storeId and mail Count is giving result but access mail mi.Subject have no
any output. I am losing any scop for public folder.

Outlook.NameSpace mapiNamespace = applicationObject.GetNamespace("MAPI");

Outlook.MAPIFolder inboxFolder =
mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders);
Outlook.MAPIFolder addinboxFolder =
inboxFolder.Folders["Public_folder"];

string storeId = addinboxFolder.StoreID;
MessageBox.Show(addinboxFolder.Items.Count.ToString(), "Count");
MessageBox.Show(storeId, "storeId ");

foreach (object oitems in addinboxFolder.Items)
{
MailItem mi = oitems as MailItem;
MessageBox.Show(mi.Subject);
}

Archived from group: microsoft>public>outlook>program_addins
Back to top
View user's profile Send private message
Ken Slovak - [MVP - Outlo



Joined: 12 Aug 2007
Posts: 405

PostPosted: Tue Feb 26, 2008 2:44 pm    Post subject: Re: access mail from public folder Reply with quote

From that snippet it doesn't look like a scoping problem.

Are you positive the items are Class == olMail?

Have you checked in the loop that addinboxFolder retains its scope?

Are you getting any exceptions?

See if instantiating an Items collection object variable helps.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"mithilesh" wrote in message @microsoft.com...
> Hi,
>
> I'm trying to use outlook 2003 and access mail from public folder.
>
> storeId and mail Count is giving result but access mail mi.Subject have no
> any output. I am losing any scop for public folder.
>
> Outlook.NameSpace mapiNamespace = applicationObject.GetNamespace("MAPI");
>
> Outlook.MAPIFolder inboxFolder =
> mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders);
> Outlook.MAPIFolder addinboxFolder =
> inboxFolder.Folders["Public_folder"];
>
> string storeId = addinboxFolder.StoreID;
> MessageBox.Show(addinboxFolder.Items.Count.ToString(), "Count");
> MessageBox.Show(storeId, "storeId ");
>
> foreach (object oitems in addinboxFolder.Items)
> {
> MailItem mi = oitems as MailItem;
> MessageBox.Show(mi.Subject);
> }
>
>
Back to top
View user's profile Send private message
mithilesh



Joined: 27 Jan 2008
Posts: 8

PostPosted: Wed Feb 27, 2008 2:26 am    Post subject: Re: access mail from public folder Reply with quote

In the loop addinboxFolder retains its scope. Coz, In the loop
addinboxFolder.Display() is open Public Folder.

NO, I am not getting any exception. While declared mi.Subject, execute the
statement before mi.subject but after mi.subject statement is not executing.
If mi.subject is comment then execute all statement.

While selecting folder Inbox inside of Public then same code execute proper
without any trouble.

Can I access Public folder mail by this way?




"Ken Slovak - [MVP - Outlook]" wrote:

> From that snippet it doesn't look like a scoping problem.
>
> Are you positive the items are Class == olMail?
>
> Have you checked in the loop that addinboxFolder retains its scope?
>
> Are you getting any exceptions?
>
> See if instantiating an Items collection object variable helps.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "mithilesh" wrote in message
> @microsoft.com...
> > Hi,
> >
> > I'm trying to use outlook 2003 and access mail from public folder.
> >
> > storeId and mail Count is giving result but access mail mi.Subject have no
> > any output. I am losing any scop for public folder.
> >
> > Outlook.NameSpace mapiNamespace = applicationObject.GetNamespace("MAPI");
> >
> > Outlook.MAPIFolder inboxFolder =
> > mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders);
> > Outlook.MAPIFolder addinboxFolder =
> > inboxFolder.Folders["Public_folder"];
> >
> > string storeId = addinboxFolder.StoreID;
> > MessageBox.Show(addinboxFolder.Items.Count.ToString(), "Count");
> > MessageBox.Show(storeId, "storeId ");
> >
> > foreach (object oitems in addinboxFolder.Items)
> > {
> > MailItem mi = oitems as MailItem;
> > MessageBox.Show(mi.Subject);
> > }
> >
> >
>
>
Back to top
View user's profile Send private message
Ken Slovak - [MVP - Outlo



Joined: 12 Aug 2007
Posts: 405

PostPosted: Wed Feb 27, 2008 2:35 pm    Post subject: Re: access mail from public folder Reply with quote

You certainly should be able to access items that way, assuming you have
sufficient permissions on that folder.

About the only thing I can think of would be to simplify the loop and step
it to see what's going on:

Outlook.Items items = addinboxFolder.Items;
int count = items.Count;
for (int i = 1; i <= count; i++)
{
object item = items[i];
if (item.Class == Outlook.OlObjectClass.olMail)
{
Outlook.MailItem mail = (Outlook.MailItem)item;
MessageBox.Show(mail.Subject);
}
}

See what you come up with.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"mithilesh" wrote in message @microsoft.com...
> In the loop addinboxFolder retains its scope. Coz, In the loop
> addinboxFolder.Display() is open Public Folder.
>
> NO, I am not getting any exception. While declared mi.Subject, execute the
> statement before mi.subject but after mi.subject statement is not
> executing.
> If mi.subject is comment then execute all statement.
>
> While selecting folder Inbox inside of Public then same code execute
> proper
> without any trouble.
>
> Can I access Public folder mail by this way?
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Exchange folder and cached folder in OST file not in sync We have written a server application that periodically accesses certain folders in Exchange user's mailboxes (for which the server has permission) and moves the messages to the Deleted Items folder. The application is a service running on Windows XP or S

C++ Outlook Addin (New Folder Code) Hi, I'm developing a Outlook Addin, simply I want to create a new folder, at same level of Inbox folder, I'd tried some code, but the folder doesn't show. Neither if I try creating this folder inside the inbox folder, I'll like to get some code sample, i

Message Class and Folder assignment Hello, I am trying to map a message class to a folder. Is there away to have messages get routed to a folder for a specific type of message class? In other words, I have a message class from a specific provider tha

Please help! Sending mail from a COM add-in Please help! I've been trying to send an email from within a COM addin in VB.net 2005, but keep getting a very weird message: 'Unable to cast object of type to type I am trying to s

How to add envid,notify and ret parameters to Outlook mail ? I'm writing an application as plugin to Outlook 2003 using VSTO. Now I have a big problem. I tried to add envid,notify and ret parameters to message header (MailItem) but I got stuck. According to SMTP envid and ret must be a
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Programs Add-Ins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group