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

Inspector outdated



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 4th 06, 11:25 AM posted to microsoft.public.outlook.program_vba
DanielH
external usenet poster
 
Posts: 6
Default 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
  #2  
Old May 4th 06, 06:54 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default 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



  #3  
Old May 4th 06, 07:00 PM posted to microsoft.public.outlook.program_vba
DanielH
external usenet poster
 
Posts: 6
Default 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




  #4  
Old May 4th 06, 07:47 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default 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






  #5  
Old May 4th 06, 07:53 PM posted to microsoft.public.outlook.program_vba
DanielH
external usenet poster
 
Posts: 6
Default 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






 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Windows form in Inspector Rog Add-ins for Outlook 1 March 17th 06 03:55 PM
Transparent Inspector images Rog Add-ins for Outlook 7 March 15th 06 10:52 PM
Right Click on Inspector Window header jim Add-ins for Outlook 1 February 18th 06 12:09 AM
Help! Inspector.Close is fired before Inspector.Activate handler finishes Sergey Anchipolevsky Add-ins for Outlook 8 February 9th 06 10:51 AM
how to add commandbarbutton to inspector window Ram Outlook and VBA 0 January 19th 06 07:07 AM


All times are GMT +1. The time now is 08:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.