Vb.net 在VB中从Outlook中提取SMTP地址

Vb.net 在VB中从Outlook中提取SMTP地址,vb.net,ms-access,outlook,smtp,Vb.net,Ms Access,Outlook,Smtp,我有一个访问脚本,可以使用smtp凭据绕过Outlook成功发送电子邮件 但是,我希望我的脚本能够自动检测每个使用该脚本的用户的smtp服务器,而不必将其硬编码到脚本中或手动键入。有人能帮忙吗 编辑: 这是我正在使用的当前代码。我不想使用任何第三方工具来实现这一点 Public Sub send_email() Dim iCfg As Object Dim iMsg As Object Dim dtm As Date Dim dtt As Date dtm = DateValue(Now)

我有一个访问脚本,可以使用smtp凭据绕过Outlook成功发送电子邮件

但是,我希望我的脚本能够自动检测每个使用该脚本的用户的smtp服务器,而不必将其硬编码到脚本中或手动键入。有人能帮忙吗

编辑:

这是我正在使用的当前代码。我不想使用任何第三方工具来实现这一点

Public Sub send_email()


Dim iCfg As Object
Dim iMsg As Object
Dim dtm As Date
Dim dtt As Date

dtm = DateValue(Now)
dtt = TimeValue(Now)

Set iCfg = CreateObject("CDO.Configuration")
Set iMsg = CreateObject("CDO.Message")
'SMTP Server settings with username and password fields
With iCfg.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "NHS-PCLI-     MBC013.AD1.NET"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =    LabelFrom.Caption
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = LabelPass.Caption
.Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = LabelFrom.Caption
.Update
End With

'Form the email with user input settings and date with time as set by system
With iMsg
.Configuration = iCfg
.From = LabelFrom.Caption
.Subject = LabelSubject.Caption & " <DB Form Sent " & dtm & " " & dtt & ">"
.To = LabelTo.Caption
.TextBody = LabelBody.Caption
.Send
MsgBox ("Email sent")
fldBody.Value = ""
Password.Value = ""
fldTo.Value = ""
fldFrom.Value = ""
fldSubject.Value = ""
LabelBody.Caption = ""
LabelTo.Caption = ""
LabelFrom.Caption = ""
LabelSubject.Caption = ""
LabelPass.Caption = ""
End With

Set iMsg = Nothing
Set iCfg = Nothing


End Sub
Public Sub send_email()
作为对象的Dim iCfg
作为对象的Dim iMsg
Dim dtm作为日期
Dim dtt作为日期
dtm=日期值(现在)
dtt=时间值(现在)
设置iCfg=CreateObject(“CDO.Configuration”)
设置iMsg=CreateObject(“CDO.Message”)
'带有用户名和密码字段的SMTP服务器设置
使用iCfg.Fields
.项目(”http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.项目(”http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.项目(”http://schemas.microsoft.com/cdo/configuration/smtpserver“”=“NHS-PCLI-MBC013.AD1.NET”
.项目(”http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.项目(”http://schemas.microsoft.com/cdo/configuration/sendusername“”=LabelFrom.Caption
.项目(”http://schemas.microsoft.com/cdo/configuration/sendpassword“”=LabelPass.Caption
.项目(”http://schemas.microsoft.com/cdo/configuration/sendemailaddress“”=LabelFrom.Caption
使现代化
以
'使用用户输入设置和日期以及系统设置的时间形成电子邮件
与iMsg
.Configuration=iCfg
.From=LabelFrom.Caption
.Subject=LabelSubject.Caption&“
.To=标签To.标题
.TextBody=LabelBody.Caption
邮寄
MsgBox(“已发送电子邮件”)
fldBody.Value=“”
Password.Value=“”
fldTo.Value=“”
fldFrom.Value=“”
fldSubject.Value=“”
LabelBody.Caption=“”
LabelTo.Caption=“”
LabelFrom.Caption=“”
LabelSubject.Caption=“”
LabelPass.Caption=“”
以
设置iMsg=无
设置iCfg=无
端接头

您可以在中阅读已配置的POP3/SMTP帐户的详细信息。

此问题似乎与主题无关,因为它缺少足够的信息来诊断问题。请更详细地描述您的问题,或者在问题本身中包含一个最小的示例。我们可以查看您现有的代码并获得更多信息吗?只是猜测,但我认为这会很棘手。如果您让用户提供“发件人”地址,那么您必须执行Mxlookup以验证SMTP,并让他们向该服务器提供凭据。