如何取得 Outlook Express 裡使用者設定的 E-Mail 信箱帳號

如何取得 Outlook Express 裡使用者設定的 E-Mail 信箱帳號

如何取得 Outlook Express 裡使用者所設定的 E-Mail 信箱帳號

從登錄檔中讀取

HKCU\Software\Microsoft\Internet Account Manager\Accounts\00000001
HKCU\Software\Microsoft\Internet Account Manager\Accounts\00000002
依此類推

VB.Net 寫法 :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

MessageBox.Show (GetEmailBox)

End Sub

Private Function GetEmailBox() As String

Dim strKey As String = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\"

Dim bytLoop As Byte

On Error Resume Next

With CreateObject("WScript.Shell")

For bytLoop = 1 To 255

GetEmailBox &= .RegRead(strKey & Format(bytLoop, "00000000") & "\SMTP Email Address") & vbCrLf

If Err.Number > 0 Then Exit For

Next

End With

End Function

================================================================

VB6 寫法 :

Dim strMail As String

Dim objWshShell As Object

Dim bytLoop As Byte

Set objWshShell = CreateObject("WScript.Shell")

On Error Resume Next

With objWshShell

For bytLoop = 1 To 255

strMail = strMail & .RegRead("HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & _

Format(bytLoop, "00000000") & "\SMTP Email Address") & vbCrLf

If Err Then Exit For

Next

End With

Set objWshShell = Nothing

MsgBox strMail