outlook-object-model

Dynamically load and use COM object in C#

风流意气都作罢 提交于 2019-12-04 11:05:43
I have a C# project, where I would like to access MS outlook, if it is installed on a client´s machine. The "access outlook" part has been done by referencing the outlook COM object, and going from there. My problem is now the "if it is installed" part. At the moment, my project doesn´t compile on machines without outlook installed, so I assume that I will have to not reference the outlook component, and instead load and use it dynamically, after detecting that outlook is present, but I haven´t found a way to do this. Am I correct, and does anybody have any hints on how to do this? Thanks.

Open Event of Window and Handle of Window

ⅰ亾dé卋堺 提交于 2019-12-04 06:37:46
问题 How do I get a window handle (IntPtr) from the Outlook window I have just opened? OutLook.Items items = oFolder.Items; foreach (OutLook.MailItem mail in items) { mail.Display(); //IntPtr a = (System.IntPtr)mail.GetInspector.Parent; I am new to C sharp. 回答1: I think I'll have to settle with this solution. I was hoping for something a lot more solid, but this is about 80% solid. Interested to see what others think. Its standard get window by window title: Process[] processes = Process

Outlook Object Model - Detecting Mailboxes

不打扰是莪最后的温柔 提交于 2019-12-04 06:15:59
问题 I have a Delphi 2006 BDS application with the following code to iterate outlook mailboxes and then the Inbox and Sent Items within the mailbox: try nameSpace := outlook.GetNameSpace('MAPI'); // load the mailboxes mailbox := NameSpace.Folders; for i := 1 to mailbox.Count do if Pos('MAILBOX', UpperCase(mailbox.Item[i].Name)) > 0 then begin rootNode := trvwOutlookFolders.Items.AddChildObject(nil, mailbox.Item[i].Name, nil); for j := 1 to mailbox.Item[i].Folders.Count do if (Pos('INBOX',

Searching Global Address List/Book

感情迁移 提交于 2019-12-03 16:23:54
I'm developing an app that will allow the user user to view the contents of an inbox that they have access to. I am having a difficult time trying to find a means of searching the Global Address List other then AddressEntries entries = global.AddressEntries; AddressEntry entry = entries["search value"]; This works but only returns one instance, and it is the first one found. I basically want to provide a list to the user if there are multiple results. Secondly I would like to be able to view the contact details, but when I use the ContactItem contact = entry.GetContact(); It always returns

Outlook Object Model - Detecting Mailboxes

蓝咒 提交于 2019-12-02 09:57:45
I have a Delphi 2006 BDS application with the following code to iterate outlook mailboxes and then the Inbox and Sent Items within the mailbox: try nameSpace := outlook.GetNameSpace('MAPI'); // load the mailboxes mailbox := NameSpace.Folders; for i := 1 to mailbox.Count do if Pos('MAILBOX', UpperCase(mailbox.Item[i].Name)) > 0 then begin rootNode := trvwOutlookFolders.Items.AddChildObject(nil, mailbox.Item[i].Name, nil); for j := 1 to mailbox.Item[i].Folders.Count do if (Pos('INBOX', UpperCase(mailbox.Item[i].Folders[j].Name)) > 0) or (Pos('SENT ITEMS', UpperCase(mailbox.Item[i].Folders[j]

Open Event of Window and Handle of Window

自闭症网瘾萝莉.ら 提交于 2019-12-02 09:56:50
How do I get a window handle (IntPtr) from the Outlook window I have just opened? OutLook.Items items = oFolder.Items; foreach (OutLook.MailItem mail in items) { mail.Display(); //IntPtr a = (System.IntPtr)mail.GetInspector.Parent; I am new to C sharp. I think I'll have to settle with this solution. I was hoping for something a lot more solid, but this is about 80% solid. Interested to see what others think. Its standard get window by window title: Process[] processes = Process.GetProcessesByName("OUTLOOK"); foreach (Process p in processes) { if (p.MainWindowTitle == mail.GetInspector.Caption)

Get Smtp email from ContactInfo stored in Exchange

丶灬走出姿态 提交于 2019-12-01 11:24:54
I am using VSTO for my Outlook add-in. Currently I am processing email addresses from all Outlook contacts. There is no problem for instances of ContactInfo if EmailAddress1Type is "SMTP". But how to get email address for Exchange contact (Email1AddressType = "EX")? Redemption library is not solution for me as it is expensive just to solve this one problem. Thank you in advance, Dusan SamFlushing Here is the MSDN reference link and corresponding sample code: private const string Email1EntryIdPropertyAccessor = "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}

Get Smtp email from ContactInfo stored in Exchange

隐身守侯 提交于 2019-12-01 08:54:32
问题 I am using VSTO for my Outlook add-in. Currently I am processing email addresses from all Outlook contacts. There is no problem for instances of ContactInfo if EmailAddress1Type is "SMTP". But how to get email address for Exchange contact (Email1AddressType = "EX")? Redemption library is not solution for me as it is expensive just to solve this one problem. Thank you in advance, Dusan 回答1: Here is the MSDN reference link and corresponding sample code: private const string

No Application Quit event in Outlook?

十年热恋 提交于 2019-12-01 05:17:27
I'm using the 12.0 Interop library, which is the default for Outlook 2007. I'm actually aiming for Outlook 2003 to 2010 integration with a code example that registers to a quit event. Even though the docs say that there is an application Quit event for the Outlook app, I can't find it in the Outlook.Application object implementation. Visual Studio 2010 seems to identify Quit as a method: Question: How would one register to the Outlook application's Quit event? (if there is one, or any event that is triggered when the application quits) If possible provide some example code. Thanks! Just try to

Outlook Object Model - Detecting if email has been sent

不羁的心 提交于 2019-11-30 23:46:03
I have the following code in my test Delphi 2006 BDS application: procedure TForm1.Button1Click(Sender: TObject); const olMailItem = 0; var Outlook: OleVariant; vMailItem: variant; begin Outlook := CreateOleObject('Outlook.Application'); vMailItem := Outlook.CreateItem(olMailItem); try vMailItem.Recipients.add('anemailaddress@gmail.com'); vMailItem.Display(True); -- outlook mail message is displayed modally except end; VarClear(Outlook); end; I need to be able to detect whether the user sent the email from within the outlook screen. I tried the following code: if vMailItem.Sent then ... But