![]() |
Inspector outdated
Hi,
I am using the following code in my ItemSend-notification to get the name of the account from which the current eMail will be sent [C#-Plugin]: void applicationObject_ItemSend(object oItem, ref bool Cancel) { Outlook.MailItem Item = oItem as Outlook.MailItem; string senderAddress = ""; Outlook.Inspector OLI = Item.GetInspector; CommandBars CBs; CommandBarPopup CBP; object ID_ACCOUNTS = 31224; if(OLI==null) return; CBs = OLI.CommandBars; object type = 10; object visible = 1; CBP = CBs.FindControl(type, ID_ACCOUNTS, null, visible) as CommandBarPopup; if(CBP == null) return; object index = 1; CommandBarControl MC = CBP.Controls[index]; int pos = MC.Caption.IndexOf(' '); if(pos = 0) senderAddress = MC.Caption.Substring(0, pos); else senderAddress = MC.Caption; Actually, this kind of works, but I am always one iteration behind. Imagine, I change from default to account2, then click Send, I will receive Default. Changing it again to account2, I will get account2. Anyone knows this problem? Any workaround? Kind regards, Daniel |
Inspector outdated
You need to be checking the named MAPI properties set on the message when
you select an account rather than check the state of the dropdown control on the inspector. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Hi, I am using the following code in my ItemSend-notification to get the name of the account from which the current eMail will be sent [C#-Plugin]: void applicationObject_ItemSend(object oItem, ref bool Cancel) { Outlook.MailItem Item = oItem as Outlook.MailItem; string senderAddress = ""; Outlook.Inspector OLI = Item.GetInspector; CommandBars CBs; CommandBarPopup CBP; object ID_ACCOUNTS = 31224; if(OLI==null) return; CBs = OLI.CommandBars; object type = 10; object visible = 1; CBP = CBs.FindControl(type, ID_ACCOUNTS, null, visible) as CommandBarPopup; if(CBP == null) return; object index = 1; CommandBarControl MC = CBP.Controls[index]; int pos = MC.Caption.IndexOf(' '); if(pos = 0) senderAddress = MC.Caption.Substring(0, pos); else senderAddress = MC.Caption; Actually, this kind of works, but I am always one iteration behind. Imagine, I change from default to account2, then click Send, I will receive Default. Changing it again to account2, I will get account2. Anyone knows this problem? Any workaround? Kind regards, Daniel |
Inspector outdated
Can you please give me an example.
If I could get the final eMail-Adress which will be used this would be even better. "Dmitry Streblechenko" wrote: You need to be checking the named MAPI properties set on the message when you select an account rather than check the state of the dropdown control on the inspector. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Hi, I am using the following code in my ItemSend-notification to get the name of the account from which the current eMail will be sent [C#-Plugin]: void applicationObject_ItemSend(object oItem, ref bool Cancel) { Outlook.MailItem Item = oItem as Outlook.MailItem; string senderAddress = ""; Outlook.Inspector OLI = Item.GetInspector; CommandBars CBs; CommandBarPopup CBP; object ID_ACCOUNTS = 31224; if(OLI==null) return; CBs = OLI.CommandBars; object type = 10; object visible = 1; CBP = CBs.FindControl(type, ID_ACCOUNTS, null, visible) as CommandBarPopup; if(CBP == null) return; object index = 1; CommandBarControl MC = CBP.Controls[index]; int pos = MC.Caption.IndexOf(' '); if(pos = 0) senderAddress = MC.Caption.Substring(0, pos); else senderAddress = MC.Caption; Actually, this kind of works, but I am always one iteration behind. Imagine, I change from default to account2, then click Send, I will receive Default. Changing it again to account2, I will get account2. Anyone knows this problem? Any workaround? Kind regards, Daniel |
Inspector outdated
Not in the Outlook Object Model... You can use Extended MAPI (C++ or Delphi
only) to read the following named prop {00062008-0000-0000-C000-000000000046}, 0x8581, PT_STRING8 to get the account id, then use the recently documented IOlkAccountManager interface to retrieve the corresponding account. Once you have IOlkAccount object, you can call IOlkAccount::GetProp(0x000C001F) to read the e-mail address. If the property is not set on the message, that means the default accout is being used, so you can call IMAPISession::QueryIdentity to retrieve the current user's name and address. plug You can also use Redemption (url below) to read the account used to send the message: 'save it first to make sure MAPI can see the latest changes MailItem.Save 'reopen the given message (MailItem) as Redemption.RDOMail set Session = CreateObject("Redemption.RDOSession") Session.MAPIOBJECT = Application.Session.MAPIOBJECT set Msg = Session.GetMessageFromID(MailItem.EntryID) 'get the account info set Account = Msg.Account if (Account is Nothing) Then 'default account MsgBox Session.CurrentUser.SMTPAddress Else if Account.AccountType = 0 Then 'atPOP3 MsgBox Account.SMTPAddress end if End If /plug Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Can you please give me an example. If I could get the final eMail-Adress which will be used this would be even better. "Dmitry Streblechenko" wrote: You need to be checking the named MAPI properties set on the message when you select an account rather than check the state of the dropdown control on the inspector. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Hi, I am using the following code in my ItemSend-notification to get the name of the account from which the current eMail will be sent [C#-Plugin]: void applicationObject_ItemSend(object oItem, ref bool Cancel) { Outlook.MailItem Item = oItem as Outlook.MailItem; string senderAddress = ""; Outlook.Inspector OLI = Item.GetInspector; CommandBars CBs; CommandBarPopup CBP; object ID_ACCOUNTS = 31224; if(OLI==null) return; CBs = OLI.CommandBars; object type = 10; object visible = 1; CBP = CBs.FindControl(type, ID_ACCOUNTS, null, visible) as CommandBarPopup; if(CBP == null) return; object index = 1; CommandBarControl MC = CBP.Controls[index]; int pos = MC.Caption.IndexOf(' '); if(pos = 0) senderAddress = MC.Caption.Substring(0, pos); else senderAddress = MC.Caption; Actually, this kind of works, but I am always one iteration behind. Imagine, I change from default to account2, then click Send, I will receive Default. Changing it again to account2, I will get account2. Anyone knows this problem? Any workaround? Kind regards, Daniel |
Inspector outdated
Thanks a lot!
"Dmitry Streblechenko" wrote: Not in the Outlook Object Model... You can use Extended MAPI (C++ or Delphi only) to read the following named prop {00062008-0000-0000-C000-000000000046}, 0x8581, PT_STRING8 to get the account id, then use the recently documented IOlkAccountManager interface to retrieve the corresponding account. Once you have IOlkAccount object, you can call IOlkAccount::GetProp(0x000C001F) to read the e-mail address. If the property is not set on the message, that means the default accout is being used, so you can call IMAPISession::QueryIdentity to retrieve the current user's name and address. plug You can also use Redemption (url below) to read the account used to send the message: 'save it first to make sure MAPI can see the latest changes MailItem.Save 'reopen the given message (MailItem) as Redemption.RDOMail set Session = CreateObject("Redemption.RDOSession") Session.MAPIOBJECT = Application.Session.MAPIOBJECT set Msg = Session.GetMessageFromID(MailItem.EntryID) 'get the account info set Account = Msg.Account if (Account is Nothing) Then 'default account MsgBox Session.CurrentUser.SMTPAddress Else if Account.AccountType = 0 Then 'atPOP3 MsgBox Account.SMTPAddress end if End If /plug Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Can you please give me an example. If I could get the final eMail-Adress which will be used this would be even better. "Dmitry Streblechenko" wrote: You need to be checking the named MAPI properties set on the message when you select an account rather than check the state of the dropdown control on the inspector. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Hi, I am using the following code in my ItemSend-notification to get the name of the account from which the current eMail will be sent [C#-Plugin]: void applicationObject_ItemSend(object oItem, ref bool Cancel) { Outlook.MailItem Item = oItem as Outlook.MailItem; string senderAddress = ""; Outlook.Inspector OLI = Item.GetInspector; CommandBars CBs; CommandBarPopup CBP; object ID_ACCOUNTS = 31224; if(OLI==null) return; CBs = OLI.CommandBars; object type = 10; object visible = 1; CBP = CBs.FindControl(type, ID_ACCOUNTS, null, visible) as CommandBarPopup; if(CBP == null) return; object index = 1; CommandBarControl MC = CBP.Controls[index]; int pos = MC.Caption.IndexOf(' '); if(pos = 0) senderAddress = MC.Caption.Substring(0, pos); else senderAddress = MC.Caption; Actually, this kind of works, but I am always one iteration behind. Imagine, I change from default to account2, then click Send, I will receive Default. Changing it again to account2, I will get account2. Anyone knows this problem? Any workaround? Kind regards, Daniel |
All times are GMT +1. The time now is 07:09 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com