How to know the email by defect ? (windows)
Thanks
know the email by defect
Default?
Do you mean 'default'? This gets the default email account settings...
Code: Select all
; -----------------------------------------------------------------------------
; Retrieve default email account information (useful for letting your program send emails via SMTP, etc)
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; Look in this key if you want to retrieve more information:
; -----------------------------------------------------------------------------
; HKEY_CURRENT_USER\Identities\{.....}\Software\Microsoft\Internet Account Manager\Accounts\0000000x
; -----------------------------------------------------------------------------
#ACCOUNT = 1 ; Name of account
#EMAIL = 2 ; Email address
#DISPLAYNAME = 3 ; Display name for this account
#POP3 = 4 ; POP3 server for this account
#SMTP = 5 ; SMTP server for this account
; -----------------------------------------------------------------------------
; Default SMTP server -- james @ hi - toro . com
; -----------------------------------------------------------------------------
; Thanks, Microsoft, for making me jump through hoops just to get this information!
; -----------------------------------------------------------------------------
Procedure.s GetDefaultEmailSettings (item)
; -----------------------------------------------------------------------------
; Open "Current User/Identities" key...
; -----------------------------------------------------------------------------
; This fills in 'idkey' with a handle to the key...
If RegOpenKeyEx_ (#HKEY_CURRENT_USER, "Identities", 0, #KEY_QUERY_VALUE, @idkey) = #ERROR_SUCCESS
; -------------------------------------------------------------------------
; Find ID string for default user...
; -------------------------------------------------------------------------
; Get size of "Default User ID" data in this key, place in 'size' variable...
If RegQueryValueEx_ (idkey, "Default User ID", #NULL, #NULL, #NULL, @size) = #ERROR_SUCCESS
; Allocate memory bank of given size...
id = AllocateMemory (0, size)
; Place the "Current User/Identities/Default User ID" data into the memory bank...
If RegQueryValueEx_ (idkey, "Default User ID", #NULL, #NULL, id, @size) = #ERROR_SUCCESS
; Get the user ID string...
user$ = PeekS (id)
; Open the "... Internet Account Manager" sub-key, place in 'account' handle...
If RegOpenKeyEx_ (idkey, user$ + "\Software\Microsoft\Internet Account Manager", 0, #KEY_QUERY_VALUE, @account) = #ERROR_SUCCESS
; Get size of "Default Mail Account" data in 'account' sub-key...
If RegQueryValueEx_ (account, "Default Mail Account", #NULL, #NULL, #NULL, @size) = #ERROR_SUCCESS
; Reallocate memory for the data with new size...
id = ReAllocateMemory (0, size)
; Place "Default Mail Account" string into memory bank...
If RegQueryValueEx_ (account, "Default Mail Account", #NULL, #NULL, id, @size) = #ERROR_SUCCESS
; Store the string...
number$ = PeekS (id, size)
; Open "Accounts/{User ID}" sub-key, storing it in 'smtp' handle...
If RegOpenKeyEx_ (account, "Accounts\" + number$, 0, #KEY_QUERY_VALUE, @smtp) = #ERROR_SUCCESS
Select item
Case #ACCOUNT
key$ = "Account Name"
Case #EMAIL
key$ = "SMTP Email Address"
Case #DISPLAYNAME
key$ = "SMTP Display Name"
Case #POP3
key$ = "POP3 Server"
Case #SMTP
key$ = "SMTP Server"
Default
key$ = "Uh-oh..."
EndSelect
; Get size of string...
If RegQueryValueEx_ (smtp, key$, #NULL, #NULL, #NULL, @size) = #ERROR_SUCCESS
; Reallocate memory for string...
id = ReAllocateMemory (0, size)
; Get string...
If RegQueryValueEx_ (smtp, key$, #NULL, #NULL, id, @size) = #ERROR_SUCCESS
; Store default SMTP server string...
server$ = PeekS (id, size)
EndIf
EndIf
; Close SMTP server key...
RegCloseKey_ (smtp)
EndIf
EndIf
EndIf
; Close account key...
RegCloseKey_ (account)
EndIf
EndIf
; Free the memory bank...
FreeMemory (0)
EndIf
; Close user ID key...
RegCloseKey_ (idkey)
EndIf
ProcedureReturn server$
EndProcedure
; -----------------------------------------------------------------------------
; D E M O . . .
; -----------------------------------------------------------------------------
m$ = "Account: " + GetDefaultEmailSettings (#ACCOUNT) + Chr (10)
m$ + "Sender: " + GetDefaultEmailSettings (#DISPLAYNAME) + Chr (10)
m$ + "Address: " + GetDefaultEmailSettings (#EMAIL) + Chr (10)
m$ + "POP3 server: " + GetDefaultEmailSettings (#POP3) + Chr (10)
m$ + "SMTP server: " + GetDefaultEmailSettings (#SMTP) + Chr (10)
MessageRequester ("Information", "Default email account information:" + Chr (10) + Chr (10) + m$, #MB_ICONINFORMATION)
-
- Enthusiast
- Posts: 103
- Joined: Fri Apr 25, 2003 4:00 pm
- Location: France
Hello
Thank's for sharing, but seems not working for me !
I don't use Outlook for emailler, Opera is mine.
Then doesn't work for me and return empty strings !
Sorry.
Dominique.
I don't use Outlook for emailler, Opera is mine.
Then doesn't work for me and return empty strings !
Sorry.
Dominique.
Dominique
Windows 10 64bits. Pure basic 32bits
Windows 10 64bits. Pure basic 32bits
-
- PureBasic Expert
- Posts: 2812
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
I think this is what you want

Code: Select all
ShellExecute_(null,null, "mailto:me@world.com", Null, Null, #SW_SHOWNORMAL)