Sender email address

Add-in Express™ Support Service
That's what is more important than anything else

Sender email address
 
Dirk van Schalkwyk




Posts: 58
Joined: 2008-03-24
Hi,

I need to get the sender email address in a new mail that I am creating. I have seen your example code using MAPI but I did not quite understand this part

You should definitely set the sender account via the Accounts popup control in the new message inspector window.


I have a windows form from where I am creating a new MailItem and sending the mail. I am not using the default mail composer. I have in my account settings a default email address that Outlook sends from. I tried running your example code and it returned

Error: Can't get the sender email address.
Object reference not set to an instance of an object...


Thanks.
Posted 14 Apr, 2008 06:34:00 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Dirk.

The example was designed for Outlook add-ins.
You can read your accounts here:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676

The default account is stored in the '{ED475418-B0D6-11D2-8C3B-00104B2A6676}' value (see low 4 bytes).

Posted 14 Apr, 2008 10:53:58 Top
Dirk van Schalkwyk




Posts: 58
Joined: 2008-03-24
Hi Sergey,

I didn't understand your reply.

The example was designed for Outlook add-ins.


I am developing an Outlook add-in.

You can read your accounts here:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676

The default account is stored in the '{ED475418-B0D6-11D2-8C3B-00104B2A6676}' value (see low 4 bytes).


I went to the location you specified and read the default account value. What am I meant to do afterward?

Thanks.
Posted 14 Apr, 2008 12:34:14 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Dirk.

I just thought you meant a separate application.
Now you need to search for the account value in the subkeys of the 9375CFF0413111d3B88A00104B2A6676 key an read the 'email' value.

Posted 15 Apr, 2008 06:42:07 Top
Dirk van Schalkwyk




Posts: 58
Joined: 2008-03-24
OK. Correct me if I'm wrong. Reading the value in the subkeys is a method used for a separate application? What do I do for an Outlook add-in? Should I read the value also?

Something separate : Is there a way to create an LDAP connection within my Outlook add-in? I need to retrieve User group details off an LDAP server.

Thanks.
Posted 15 Apr, 2008 08:50:26 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Dirk, this solution works everywhere if you send emails using the default account.

As to LDAP, I think it is possible. You just need to use appropriate components of the System.DirectoryServices namespace.
Posted 15 Apr, 2008 11:14:01 Top
Dirk van Schalkwyk




Posts: 58
Joined: 2008-03-24
OK. I will have to see what I'm doing wrong.

Thanks.
Posted 15 Apr, 2008 12:11:35 Top
Dirk van Schalkwyk




Posts: 58
Joined: 2008-03-24
Hi,

I still havn't figured out what I'm doing wrong. I have set the default email account (infact, its the only account I have configured) but it's still not working.

I am thinking of accessing the user's login name. This would work well as a substitute to the email address. Is it possible for me to get the user login name in an Outlook add-in?

Thanks.
Posted 16 Apr, 2008 12:33:21 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Posted 16 Apr, 2008 12:52:27 Top
Dirk van Schalkwyk




Posts: 58
Joined: 2008-03-24
Hi Sergey,

Thanks the example you gave me is working well, although I had to move the code from a custom form class to the AddInModule class. Is there any way of obtaining account details without having to send mail first. What I actually need to do is upon start-up of the add-in I carry out an LDAP lookup to an LDAP server using the users login name (changed from the email address) as the filter key.

Is it possible to obtain the login name? If so, could you please highlight to me how I could go about it perhaps with an example.

Thanks.
Posted 16 Apr, 2008 17:07:31 Top