我用SmtpMail为用户转发网站内容。用户填写包括名字和电子邮件的表格。SmtpMail - 更改“从地址”来命名
电子邮件发送具有完整的电子邮件地址作为“发件人地址”,在收件人的收件箱(他们看到来自:[email protected]而我希望他们看到来自:乔)。
我如何格式化“从地址”是用户输入的名字?
谢谢!
我用SmtpMail为用户转发网站内容。用户填写包括名字和电子邮件的表格。SmtpMail - 更改“从地址”来命名
电子邮件发送具有完整的电子邮件地址作为“发件人地址”,在收件人的收件箱(他们看到来自:[email protected]而我希望他们看到来自:乔)。
我如何格式化“从地址”是用户输入的名字?
谢谢!
我结束了使用格式为:mailer.From = name & "<" & emailer & ">"
这格式化的地址,包括姓名以及邮箱地址。它将在大多数电子邮件客户端中显示为Joe <[email protected]>
。这是我期望的结果。
谢谢Knslyr和lincolnk的支持。
的MailAddress类有一个可选的参数,你可以指定显示名称。我认为它会在现场使用。
Dim from As MailAddress = New MailAddress("[email protected]", "Ben Miller")
Dim to As MailAddress = New MailAddress("[email protected]", "Jane Clayton")
Dim message As MailMessage = New MailMessage(from, to)
这一直为我工作:
Dim myMessage As New MailMessage
Dim myFrom As MailAddress = New MailAddress("[email protected]", "Bob Denver")
Dim myTo As MailAddress = New MailAddress("[email protected]", "Steve Miller")
myMessage.From = myFrom
myMessage.To.Add(myTo)
这种方法显示“拉梅斯”而不是“[email protected]”
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next
strBcc = """Rameez"" <[email protected]>"
Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Do you want still to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc Recipient")
If res = vbNo Then
Cancel = True
End If
End If
Set objRecip = Nothing
End Sub
这会导致网页无法加载...任何想法? – Joe 2010-10-25 20:51:36
@Joe ummmm ....不。也许发布你有问题的代码? – lincolnk 2010-10-25 20:54:48
下面是传递主要邮件变量的代码部分。 “接收者,电子邮件,nombre”是从表单中提取的3个变量。我需要“nombre”通过mailer.from字段而不是emailer。
mailer.To = receiver mailer.Bcc = "[email protected]" mailer.From = emailer mailer.BodyFormat = MailFormat.Html mailer.Subject = "Subject Line Here"
– Joe 2010-10-25 21:31:46