SmtpMail - 更改“发件人地址”命名

发布于 2024-09-28 16:16:19 字数 276 浏览 3 评论 0原文

我使用 SmtpMail 供用户转发网站内容。用户填写包含名字和电子邮件的表格。

发送的电子邮件具有完整的电子邮件地址作为收件人收件箱中的“发件人地址”(他们看到发件人:[电子邮件受保护],而我希望他们看到发件人:乔)。

如何将“发件人地址”格式化为用户输入的名字?

谢谢!

I use SmtpMail for users to forward site content. The user fills out a form which includes first name and email.

The email sent has the full email address as the "From address" in the recipients inbox (they see From: [email protected] while I want them to see From: Joe).

How can I format the "From address" to be the users inputted first name?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

や莫失莫忘 2024-10-05 16:16:19

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)

The MailAddress class has an optional parameter where you can specify a display name. I assume it will be used when present.

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)
初懵 2024-10-05 16:16:19

这一直对我有用:

    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)

This has always worked for me:

    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)
忘东忘西忘不掉你 2024-10-05 16:16:19

我最终使用的格式是: mailer.From = name & “<” &电子邮件发送器和">"

这会格式化发件人地址以包括姓名和电子邮件地址。它将在大多数电子邮件客户端中显示为 Joe <[email protected]< /a>>。这是我想要的结果。

感谢 Knslyr 和 lincolnk 的支持。

The format I ended up using was: mailer.From = name & "<" & emailer & ">"

This formats the from address to include Name as well as Email address. It will be displayed in most email clients as Joe <[email protected]>. This was my desired outcome.

Thank you Knslyr and lincolnk for the support.

踏月而来 2024-10-05 16:16:19

此方法显示“Rameez”而不是“[电子邮件受保护]

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

this method displays 'Rameez' instead of '[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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文