向电话号码发送电子邮件在电话上被中断

问题描述 投票:0回答:1

我的任务是在程序中发送短信。我使用 Net.Mail 和电话运营商提供的电子邮件结尾列表可以正常发送,但手机上的文本在收到时被分成 3 部分。

我的代码如下:

'Email Customer
Dim strTo As String = ""
If Customer.NotifyByEmail Then
    strTo = Customer.Email
End If
If Customer.NotifyByText Then
    If strTo <> "" Then
        strTo &= "," & Customer.PhoneNumber & Customer.PhoneEmailEnding
    Else
        strTo = Customer.PhoneNumber & Customer.PhoneEmailEnding
    End If
End If

If strTo <> "" Then
    Using oMailMsg As New Net.Mail.MailMessage
        Using SmtpMail As New System.Net.Mail.SmtpClient With {
            .Host = "mail.server.com",
            .Port = 587,
            .DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network,
            .EnableSsl = True,
            .Credentials = New System.Net.NetworkCredential("[email protected]", "#####")
        }
            Dim sFrom As New Net.Mail.MailAddress("[email protected]")
            oMailMsg.From = sFrom

            If strTo.Contains(","c) Then
                Dim arMultiTo As String() = Strings.Split(strTo, ",")
                For Each strCurTo As String In arMultiTo
                    Dim sTo As New Net.Mail.MailAddress(strCurTo.Trim)
                    oMailMsg.To.Add(sTo)
                Next
            Else
                Dim sTo As New Net.Mail.MailAddress(strTo.Trim)
                oMailMsg.To.Add(sTo)
            End If

            oMailMsg.Subject = "Your Surfboard Repair Has Been Picked Up"

            'Build the message body (text only)
            oMailMsg.IsBodyHtml = False

            oMailMsg.Body = "This message is to notify you that the board you dropped off for repair has been picked up by the repairman. Your contact info has been passed on to them and they may contact you if they have questions about the repair."

            SmtpMail.Send(oMailMsg)
            oMailMsg.Dispose()
        End Using
    End Using
End If

收到的文本为:

1 of 3
FRM:[email protected]
SUBJ:Your Surfboard Repair Has Been Picked Up
MSG:This message is to notify you that the board you dropped
(Con't) 2 of 3
off for repair has been picked up by the repairman. Your contact info has been passed on to them and they may contact you if they have
(Con't) 3 of 3
questions about the repair.

这读起来很混乱。这都是一条短信...邮件缓冲区是否发生了某种情况,导致消息在发送时被分割?有没有办法让它作为一条完整的消息而不是 3 个部分发送?

我已经研究了 MailMessage 和 SmptClient 下的可用选项,但没有找到任何看起来像缓冲区大小的内容。我已经在 true 和 false 之间切换了 IsBodyHtml,这没有改变任何东西。

-编辑- 修改消息正文以包含 HTML 也没有帮助,手机完全忽略格式,

<br/>
甚至不留空格,而且它仍然分为 3 部分。

vb.net sms system.net.mail
1个回答
0
投票

在 Andrew 和 user246821 的评论中的帮助下,我能够确定我的问题不在我的代码中,或者错过了发送消息的步骤。因此,如果有人想通过电子邮件向手机发送短信,只要您填写 10 位数字的电话号码和电话提供商表中以正确结尾的电子邮件,我的代码就可以正常工作。

字符限制是短信平台的限制,这是我的电子邮件发送到的平台,但是在电话提供商表中,大多数运营商现在支持彩信,这是较新的并且没有相同的限制。因此,目前,如果支持的话,我将使用每个电话提供商的彩信电子邮件来发送短信。如果我们这部分业务稍后扩展并且我们需要发送的不仅仅是简短的快速更新,我们将考虑使用 Twillio 或 Constant Contact 等付费服务。

© www.soinside.com 2019 - 2024. All rights reserved.