Mixing Simple MAPI and Outlook code isn't ever going to work right, and
using Outlook automation from outside Outlook will fire the security prompts
unless you're running Outlook 2007 with up-to-date anti-virus software.
Calling a procedure within a VSTO addin from the outside world is somewhat
different than performing the same function with other types of addins. It's
also different depending on what version of VSTO you're using, which you
don't mention.
Rather than show a lot of code here probably the best way for you to get a
feel of what you need to do is to look at one of the templates I've posted
on my Web site, assuming you're using VSTO 2005 SE and Outlook 2007. I have
VSTO templates posted for both C# and VB.NET. The relevant pieces are the
AutomationObject class and the code in ThisAddIn that references
RequestComAddInAutomationService and IAddinUtilities.
Take a look at the templates at
http://www.slovaktech.com/outlook_2007_templates.htm to see how I handled
that sort of communications.
--
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
"njdude" <njdude31.TakeThisOut@gmail.com> wrote in message
news:1186281132.369868.295140@19g2000hsx.googlegroups.com...
>I would like to acheive this. Please read below.
>
> the Answers im looking for
> With MAPIMessage & MAPISendMail and tried to set the messageType to
> myform. Somehow it does not like it. I dont know why . It throws an
> error saying invalid type
>
> Or is there any way to communicate with a Outlook Addin from Excel so
> that I can just activate the button click on the already opened
> Outlook ?
>
> I have a custom outlook form which i have created. I have created an
> VSTO Addin in outlook which handles a button in the ribbon to launch
> this form and then some details have to be filled in by the user and
> the email is sent. the user can attach documents as well. This works
> perfectly.
>
> Now If a user uses excel i want to provide him the option to open this
> particular email form with the excel document he is using attached to
> the email. I have built an Excel addin to handle a ribbon button which
> allows a user to launch this mail form. Im presently using the code
> below
>
> outLookAppln = new OutLook.Application();
>
> OutLook.MAPIFolder templateFolder =
> outLookAppln.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
> myItem =
> (OutLook.MailItem)templateFolder.Items.Add("IPM.Note.MyForm");
> outLookAppln.ItemSend += new
> Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(outLookAppln_ItemSend);
> string strSourceFileName = docFileName;
> string strDisplayName = "Attachment";
> int intPosition = 1;
> int intAttachType =
> (int)OutLook.OlAttachmentType.olByValue;
> OutLook.Attachment oAttach =
> myItem.Attachments.Add(docFileName, intAttachType, intPosition,
> strDisplayName);
>
> myItem.Display(objFalse);
>
>
> Everything works except that i have a button in the form which
> basically lets users select recipients from the Outlook Address book
> with specific properties. This will launch an addressbook UI with all
> the relevant recipients. Im using Extended MAPI to get recipients.
> Everything is fine till i add the selected recips to myItem and call
> Resolve . Then I get the Outlook Security Popup.
> So what is the solution to this
>
> I tried using MAPIMessage & MAPISendMail and tried to set the
> messageType to myform. Somehow it does not like it. I dont know why .
> If this works then Excel can launch the form without any issues and i
> dont think the security dialog will popup because it is running in
> outlooks context.
>
> Or is there any way to communicate with the Outlook Addin so that I
> can just activate the button click on the already opened Outlook ?
> Please help !!
>