There may be a way capture the SMTP Server but unfortunately I am not aware of it. Typically I have my app prompt the user for their email settings and then write the info to an INI file or to the registry.
-----------------------------------------------------------Sample INI File example: MyAppName.ini
[MAIL SETTINGS]
Enabled=False
Port =25
Host =smtp1.yahoo.com
From=optional@useraddress.com
Subject=Optional Subject line
Comment=Optional Comment Line
----------------------------------------------------------
Sample VB Code
‘API’s used for reading and writing to INI Files
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
Public MyIni as String
Public SMTPPort as Integer
Public SMTPHost as String
Private Sub Read_Ini_Sample()
Dim Temp As String * 300
Dim ReadLine As Integer
Dim HelpDocument As String
MyINI = App.Path & "\ MyAppName.ini "
ReadLine = GetPrivateProfileString("EMAIL SETTINGS", _
“Port", 25, Temp, Len(Temp), MyINI)
SMTPPort = Cint(Left$(Temp, Len(Temp)))
ReadLine = GetPrivateProfileString("EMAIL SETTINGS", _
“Host", “NOT FOUND”, Temp, Len(Temp), MyINI)
SMTPHost = Left$(Temp, Len(Temp))
End Sub
Private Sub Write_Ini_Sample()
Dim WriteLine As Integer
SMTPHost = InputBox(“Please enter name of your SMTP Host”)
WriteLine = WritePrivateProfileString("EMAIL SETTINGS", _
"Host", SMTPHost, MyINI)
End Sub