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 » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , , , , , ,

Trying to open the new mailItem inspector form within a custom Win





 
 
Thread Tools Display Modes
  #1  
Old May 10th 08, 03:36 AM posted to microsoft.public.outlook.program_addins
Naji
external usenet poster
 
Posts: 8
Default Trying to open the new mailItem inspector form within a custom Win

Good evening everybody,

I am working on a VST add-in. I am using C#, Outlook 2007 and VS2008

I have a Toolbar button that, when clicked, opens a windows form. This part
works fine. However, what I am having a problem with is trying to,
programmatically, open a new mailItem inspector by clicking on a button that
resides on the windows form.
I need to do it in this fashion to:
1- be able to populate the mailitem properties using the winForm fields
2- avoid recreating all the functionality(attachment,spell check, follow
up, address book, etc ) that is already built into the mail inspector window

My question: is it possible to open a new Message Inspector from withing a
windows form that is part of an Outlook add-in?
If the answer is yes, and I hope so, How would you do it?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~

Here is what I have in place so far:

public void CreateNewMail(string subject)
{
Outlook.MailItem mail = null;
Outlook.Application m_Outlook = null;

try
{
m_Outlook = Globals.ThisAddIn.Application;

mail =
(Outlook.MailItem)m_Outlook.CreateItem(Outlook.OlI temType.olMailItem);
mail.Subject = subject;
mail.Display(false);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (mail != null)
Marshal.ReleaseComObject(mail);
}
}


Thank you for your time and effort.
Ads
  #2  
Old May 12th 08, 02:03 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,411
Default Trying to open the new mailItem inspector form within a custom Win

What's wrong with using mail.Display()? Just create the item when your
button is clicked and call Display() on the item. If you want a handle to
the Inspector for the item just use mail.GetInspector().

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


"Naji" wrote in message
...
Good evening everybody,

I am working on a VST add-in. I am using C#, Outlook 2007 and VS2008

I have a Toolbar button that, when clicked, opens a windows form. This
part
works fine. However, what I am having a problem with is trying to,
programmatically, open a new mailItem inspector by clicking on a button
that
resides on the windows form.
I need to do it in this fashion to:
1- be able to populate the mailitem properties using the winForm fields
2- avoid recreating all the functionality(attachment,spell check, follow
up, address book, etc ) that is already built into the mail inspector
window

My question: is it possible to open a new Message Inspector from withing a
windows form that is part of an Outlook add-in?
If the answer is yes, and I hope so, How would you do it?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~

Here is what I have in place so far:

public void CreateNewMail(string subject)
{
Outlook.MailItem mail = null;
Outlook.Application m_Outlook = null;

try
{
m_Outlook = Globals.ThisAddIn.Application;

mail =
(Outlook.MailItem)m_Outlook.CreateItem(Outlook.OlI temType.olMailItem);
mail.Subject = subject;
mail.Display(false);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (mail != null)
Marshal.ReleaseComObject(mail);
}
}


Thank you for your time and effort.


  #3  
Old May 12th 08, 02:44 PM posted to microsoft.public.outlook.program_addins
Naji
external usenet poster
 
Posts: 8
Default Trying to open the new mailItem inspector form within a custom

Good morning Ken,

Thank you for your response.

Nothing is wrong with [mail.Display], if you take a look at the code snippet
I included in my initial post, I am making use of it. The problem, though, is
that in order to get a reference to a new mailItem, you need to use
[This.Application.CreateItem...], and since I am making the call from within
a winform, [This.Application] would not work. To solve this problem, I am
using [Globals.ThisAddIn.Application], but this call throws an exception and
that is my problem.

So once I successfully create a mailItem, I would definitely call the
[Display ] method on that Item.

Thank you Ken.

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

What's wrong with using mail.Display()? Just create the item when your
button is clicked and call Display() on the item. If you want a handle to
the Inspector for the item just use mail.GetInspector().

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


"Naji" wrote in message
...
Good evening everybody,

I am working on a VST add-in. I am using C#, Outlook 2007 and VS2008

I have a Toolbar button that, when clicked, opens a windows form. This
part
works fine. However, what I am having a problem with is trying to,
programmatically, open a new mailItem inspector by clicking on a button
that
resides on the windows form.
I need to do it in this fashion to:
1- be able to populate the mailitem properties using the winForm fields
2- avoid recreating all the functionality(attachment,spell check, follow
up, address book, etc ) that is already built into the mail inspector
window

My question: is it possible to open a new Message Inspector from withing a
windows form that is part of an Outlook add-in?
If the answer is yes, and I hope so, How would you do it?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~

Here is what I have in place so far:

public void CreateNewMail(string subject)
{
Outlook.MailItem mail = null;
Outlook.Application m_Outlook = null;

try
{
m_Outlook = Globals.ThisAddIn.Application;

mail =
(Outlook.MailItem)m_Outlook.CreateItem(Outlook.OlI temType.olMailItem);
mail.Subject = subject;
mail.Display(false);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (mail != null)
Marshal.ReleaseComObject(mail);
}
}


Thank you for your time and effort.



  #4  
Old May 12th 08, 04:06 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,411
Default Trying to open the new mailItem inspector form within a custom

What exception are you getting? I call my "global" Outlook.Application
object from lots of places in my code, including from within Windows forms
with no exceptions.

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


"Naji" wrote in message
...
Good morning Ken,

Thank you for your response.

Nothing is wrong with [mail.Display], if you take a look at the code
snippet
I included in my initial post, I am making use of it. The problem, though,
is
that in order to get a reference to a new mailItem, you need to use
[This.Application.CreateItem...], and since I am making the call from
within
a winform, [This.Application] would not work. To solve this problem, I am
using [Globals.ThisAddIn.Application], but this call throws an exception
and
that is my problem.

So once I successfully create a mailItem, I would definitely call the
[Display ] method on that Item.

Thank you Ken.


  #5  
Old June 16th 08, 03:52 PM posted to microsoft.public.outlook.program_addins
Jason Wang
external usenet poster
 
Posts: 4
Default Trying to open the new mailItem inspector form within a custom

I got an error "A dialog box is open. Close it and try again."

My code he

Outlook.Application thisApp = Globals.ThisAddIn.Application;
Outlook.NameSpace ns = thisApp.GetNamespace("MAPI");
Outlook.MAPIFolder appointmentFolder = thisApp.Session.GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderCalendar);

object o =
ns.GetItemFromID("000000009408AECE65C0E84BAB4CE89B 19E6944FA4642100",
appointmentFolder.StoreID);

Outlook.AppointmentItem appointmentItem = (Outlook.AppointmentItem)o;
appointmentItem.Display(false); // or true

Jason

  #6  
Old June 17th 08, 02:30 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,411
Default Trying to open the new mailItem inspector form within a custom

I don't see where that code is creating the appointment item, but what line
triggers the dialog box open message?

Is the thisApp object valid when you get it? Have you looked at it in debug
mode?

If worst came to worst you could always just set your Outlook.Application
object before calling Show on your form from wherever the form is called.

Also, if you have a NameSpace object why use thisApp.Session? Just use ns
instead.

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


"Jason Wang" wrote in message
news
I got an error "A dialog box is open. Close it and try again."

My code he

Outlook.Application thisApp = Globals.ThisAddIn.Application;
Outlook.NameSpace ns = thisApp.GetNamespace("MAPI");
Outlook.MAPIFolder appointmentFolder = thisApp.Session.GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderCalendar);

object o =
ns.GetItemFromID("000000009408AECE65C0E84BAB4CE89B 19E6944FA4642100",
appointmentFolder.StoreID);

Outlook.AppointmentItem appointmentItem = (Outlook.AppointmentItem)o;
appointmentItem.Display(false); // or true

Jason


 




Thread Tools
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
Access to MailItem properties before opening new inspector ? Marcin Add-ins for Outlook 8 April 25th 08 07:50 PM
Spell check on custom MailItem form when replying István Becze Add-ins for Outlook 1 June 27th 07 02:14 PM
Is it possible to open the default Contact form with the Activities tab activated from a custom form? VSTO 2005, Outlook 2003 David Webb Outlook and VBA 1 June 20th 06 09:59 PM
Help with 'MailItem' object of WordMail Inspector gspence1@gmail.com Add-ins for Outlook 2 May 18th 06 07:28 PM
Cannot programmatically open custom message in custom form ms Outlook - Using Forms 1 January 20th 06 03:01 PM


All times are GMT +1. The time now is 10:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Music Festival - Cheap Car Insurance - Pay Day Loans - Buy Anything On eBay - Mortgage Calculator