Determine Default Email Sender?

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

I'm writing a simple EXE in VB.NET to be run on our intranet (Win2K network,
XP machines). When it's done running I want to notify the user via email.
I've got the email working...how do I ascertain the user's default email
address without user interaction? There is only one user per machine, and we
are all using Outlook or Outlook Express.

Thanks.
 
Hi Jason!

I don't know if this will help you but i thought i could share it anyway...

check this registry key out :
HKEY_CURRENT_USER\Software\Microsoft\Internet Account Manager\Accounts

i've 2 account (shown as reg keys) named "00000001" and "00000002".
the first one (00000001) is for my hotmail account.
there is a value in there named "SMTP Email Address" which is my email
address.


if you don't find anything much information here about this you might want
to visit the different Outlook groups out there and ask them where this kind
of information could be find.
 
Jason,

You can collect those adresses in a database on your Lan and use as key for
that the environment.username.

I hope this helps,

Cor
 
Hi

I wrote a function that returns the default e-mail address (smtp) from the
registry

Add this import:

Imports Microsoft.Win32

Function:

Private Function GetDefaultEmail() As String
Dim strkey As String = "Software\Microsoft\Internet Account Manager"
Dim reg As RegistryKey
Dim regDefaultAccount As RegistryKey
Dim strTemp As String
Dim strAccountNumber As Integer
reg = Registry.CurrentUser.OpenSubKey(strkey, False)
strAccountNumber = reg.GetValue("Default Mail Account")
reg.Close()
regDefaultAccount = Registry.CurrentUser.OpenSubKey(strkey &
"\Accounts\" & String.Format("{0:X8}", strAccountNumber), False)
strTemp = regDefaultAccount.GetValue("SMTP Email Address")
regDefaultAccount.Close()
If (Not strTemp Is Nothing) Then
Return strTemp
Else
Return ""
End If
End Function

Returns the default e-mail address or "" if the function fails

As you have noticed from above I returned the default account number as a
string, which on my machine would be just '1'. So, I needed a way to add the
zeros & using 'String.Format("{0:X8}", strAccountNumber)' does exactly that.
I am not sure if all the addresses held in the registry are in hex or
decimal. If they are decimal then you could format it like so:

String.Format("{0:D8}", strAccountNumber) '

I hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top