PC Review


Reply
Thread Tools Rate Thread

New Mail Item Event

 
 
Neetu
Guest
Posts: n/a
 
      2nd Apr 2008
I am creating a outlook add-in .on clicking on any custom folder created by
our add-in, we are opening windows forms.
according to requirement , if some exception occours, we are providing a
link button on errror form ( a window form with link button). on clicking on
link we have to send mail from outlook.
I am opening a mail item inside outlook programmatically. I m doing this like.

MailItem lobjNewMailitem =
(MailItem)Application.CreateItem(OlItemType.olMailItem);
Microsoft.Office.Interop.Outlook.Application lobjApplication =
this.Application;
Microsoft.Office.Interop.Outlook.Inspector lobjInspector;
lobjInspector = lobjApplication.Inspectors.Add(lobjNewMailitem);
lobjNewMailitem = (MailItem)lobjInspector.CurrentItem;

lobjInspector.Activate();
lobjInspector.Display(lobjNewMailitem);

above code work fine if in case no other custom folder is opened inside
outlook.
eg -> when user first time open outlook and if exception occurs.

however soppose , if already other custom winform is opened like "Filter
form" ( one of the windows form )
this code doesn't work..

it says

"A dialog Box is open. close it and try again"

Inside code before displaying new mail item , i m explicitly closing all
possible forms like in our case we have 2 forms. so i m checking for them and
closing all.
still I m getting this exception.
I am using c#, and VSTO for outlook 2007

any suggesstion would be g8 help.!!
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      2nd Apr 2008
If you have a modal form open in your addin you can't open a new item until
that form is closed or hidden. It's the same in any language you use (C#,
VB.NET, VB6, C++, etc.).

You can either hide or close your form when you want to open an Outlook
item.

--
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


"Neetu" <(E-Mail Removed)> wrote in message
news:12B4CF9A-5002-4EB6-BFFA-(E-Mail Removed)...
>I am creating a outlook add-in .on clicking on any custom folder created by
> our add-in, we are opening windows forms.
> according to requirement , if some exception occours, we are providing a
> link button on errror form ( a window form with link button). on clicking
> on
> link we have to send mail from outlook.
> I am opening a mail item inside outlook programmatically. I m doing this
> like.
>
> MailItem lobjNewMailitem =
> (MailItem)Application.CreateItem(OlItemType.olMailItem);
> Microsoft.Office.Interop.Outlook.Application lobjApplication =
> this.Application;
> Microsoft.Office.Interop.Outlook.Inspector lobjInspector;
> lobjInspector = lobjApplication.Inspectors.Add(lobjNewMailitem);
> lobjNewMailitem = (MailItem)lobjInspector.CurrentItem;
>
> lobjInspector.Activate();
> lobjInspector.Display(lobjNewMailitem);
>
> above code work fine if in case no other custom folder is opened inside
> outlook.
> eg -> when user first time open outlook and if exception occurs.
>
> however soppose , if already other custom winform is opened like "Filter
> form" ( one of the windows form )
> this code doesn't work..
>
> it says
>
> "A dialog Box is open. close it and try again"
>
> Inside code before displaying new mail item , i m explicitly closing all
> possible forms like in our case we have 2 forms. so i m checking for them
> and
> closing all.
> still I m getting this exception.
> I am using c#, and VSTO for outlook 2007
>
> any suggesstion would be g8 help.!!


 
Reply With Quote
 
 
 
 
Neetu
Guest
Posts: n/a
 
      3rd Apr 2008
Yes Ken. That Y before opening ne main item, i m explicity closing all
possible forms. we have total 2 forms inside our project. still i m getting
this error message.
Is there any way to find any open modal form inside outlook?



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

> If you have a modal form open in your addin you can't open a new item until
> that form is closed or hidden. It's the same in any language you use (C#,
> VB.NET, VB6, C++, etc.).
>
> You can either hide or close your form when you want to open an Outlook
> item.
>
> --
> 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
>
>
> "Neetu" <(E-Mail Removed)> wrote in message
> news:12B4CF9A-5002-4EB6-BFFA-(E-Mail Removed)...
> >I am creating a outlook add-in .on clicking on any custom folder created by
> > our add-in, we are opening windows forms.
> > according to requirement , if some exception occours, we are providing a
> > link button on errror form ( a window form with link button). on clicking
> > on
> > link we have to send mail from outlook.
> > I am opening a mail item inside outlook programmatically. I m doing this
> > like.
> >
> > MailItem lobjNewMailitem =
> > (MailItem)Application.CreateItem(OlItemType.olMailItem);
> > Microsoft.Office.Interop.Outlook.Application lobjApplication =
> > this.Application;
> > Microsoft.Office.Interop.Outlook.Inspector lobjInspector;
> > lobjInspector = lobjApplication.Inspectors.Add(lobjNewMailitem);
> > lobjNewMailitem = (MailItem)lobjInspector.CurrentItem;
> >
> > lobjInspector.Activate();
> > lobjInspector.Display(lobjNewMailitem);
> >
> > above code work fine if in case no other custom folder is opened inside
> > outlook.
> > eg -> when user first time open outlook and if exception occurs.
> >
> > however soppose , if already other custom winform is opened like "Filter
> > form" ( one of the windows form )
> > this code doesn't work..
> >
> > it says
> >
> > "A dialog Box is open. close it and try again"
> >
> > Inside code before displaying new mail item , i m explicitly closing all
> > possible forms like in our case we have 2 forms. so i m checking for them
> > and
> > closing all.
> > still I m getting this exception.
> > I am using c#, and VSTO for outlook 2007
> >
> > any suggesstion would be g8 help.!!

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      3rd Apr 2008
Hmm, see if it's any better if you don't use an Inspector at all when you
create the mail item, something like this:

MailItem lobjNewMailitem =
(MailItem)Application.CreateItem(OlItemType.olMailItem);

lobjNewMailItem.Display(false);

If Outlook is actually displaying an error or warning message that could
also be the problem. In that case about all you can do is to make sure the
error doesn't occur with lots of checking to prevent the error in the first
place.

--
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


"Neetu" <(E-Mail Removed)> wrote in message
news:809CB4C9-4F49-4095-9C91-(E-Mail Removed)...
> Yes Ken. That Y before opening ne main item, i m explicity closing all
> possible forms. we have total 2 forms inside our project. still i m
> getting
> this error message.
> Is there any way to find any open modal form inside outlook?
>


 
Reply With Quote
 
Neetu
Guest
Posts: n/a
 
      4th Apr 2008
Hi Ken,

I found some other alternative . directly sending mail .
lobjNewMailItem.send();

Ken, is there any way to find where outlook is in offline or online..
so that if I fire this statement i can give appropriate message and save the
message in his/her mail box.


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

> Hmm, see if it's any better if you don't use an Inspector at all when you
> create the mail item, something like this:
>
> MailItem lobjNewMailitem =
> (MailItem)Application.CreateItem(OlItemType.olMailItem);
>
> lobjNewMailItem.Display(false);
>
> If Outlook is actually displaying an error or warning message that could
> also be the problem. In that case about all you can do is to make sure the
> error doesn't occur with lots of checking to prevent the error in the first
> place.
>
> --
> 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
>
>
> "Neetu" <(E-Mail Removed)> wrote in message
> news:809CB4C9-4F49-4095-9C91-(E-Mail Removed)...
> > Yes Ken. That Y before opening ne main item, i m explicity closing all
> > possible forms. we have total 2 forms inside our project. still i m
> > getting
> > this error message.
> > Is there any way to find any open modal form inside outlook?
> >

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      4th Apr 2008
Sure. In Outlook 2007 you have a couple of things you can check:

NameSpace.ExchangeConnectionMode
NameSpace.Offline

Review the Object Browser help on those properties.

--
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


"Neetu" <(E-Mail Removed)> wrote in message
news7501284-2894-4139-A15B-(E-Mail Removed)...
> Hi Ken,
>
> I found some other alternative . directly sending mail .
> lobjNewMailItem.send();
>
> Ken, is there any way to find where outlook is in offline or online..
> so that if I fire this statement i can give appropriate message and save
> the
> message in his/her mail box.


 
Reply With Quote
 
Neetu
Guest
Posts: n/a
 
      4th Apr 2008
Hey Ken, thanks a lot.

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

> Sure. In Outlook 2007 you have a couple of things you can check:
>
> NameSpace.ExchangeConnectionMode
> NameSpace.Offline
>
> Review the Object Browser help on those properties.
>
> --
> 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
>
>
> "Neetu" <(E-Mail Removed)> wrote in message
> news7501284-2894-4139-A15B-(E-Mail Removed)...
> > Hi Ken,
> >
> > I found some other alternative . directly sending mail .
> > lobjNewMailItem.send();
> >
> > Ken, is there any way to find where outlook is in offline or online..
> > so that if I fire this statement i can give appropriate message and save
> > the
> > message in his/her mail box.

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
create new mail item from current item lindstrom Microsoft Outlook VBA Programming 4 25th May 2010 02:24 AM
dictionary->(item, item, item); Can dictionary point to an array inVBA? cate Microsoft Excel Programming 1 6th Mar 2010 11:15 PM
open mail item using mail item ID masani paresh Microsoft Outlook VBA Programming 3 2nd Mar 2009 05:23 PM
Event ID: 1003, Event Type: Error ,Event Source: System Error,Event Category: (102) BoazBoaz Windows XP General 0 21st Jun 2006 05:39 PM
Create mail item with mail item as attachment eselk@surfbest.net Microsoft Outlook Program Addins 6 7th Jul 2005 04:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:17 PM.