1

VB アプリケーション経由でメールを送信しています。次の文字は、一部の電子メール アプリケーションでは正しく表示されますが、他のアプリケーションでは奇妙な置換が行われます (添付の画像を参照)。これらの文字を常に正しく表示するにはどうすればよいですか?

文字セット: ( ) & * % $ # @ ! 〜; _ = + / - ?

メッセージ:幅18cm~22cm。ファットオー

結果 :ここに画像の説明を入力

どのキャラクターが使われても、結果は常に添付画像と同じです。正しく表示されないアプリケーションは、outlook < 2013 です。

VBコードは次のとおりです。

Sub subHtmlEmail(ByVal strAddresseeEmail As String, ByVal strGroup As String)
    Try
        Dim strTo, strFrom, strBody, strSubject, strBcc As String
        Dim boolHtml As Boolean = True ' set the body content to plain text(false) or HTML(true)
        strFrom = "sales@humeat.com"
        strTo = strAddresseeEmail ' ; Separates emails
        strBcc = "" ' ; Separates emails

        strSubject = txtEmailSubject.Text

        strBody = "<html><head></head><body>"
        strBody = strBody & "<img src=cid:Logo>"
        strBody &= "<br><br>"


        strBody &= "Dear " & clsGroupCustomers.RetrieveAddressee(strAddresseeEmail, strGroup) & ",<br><br>"

        Dim strLines As String() = txtBody.Text.Split(New [Char]() {CChar(vbCrLf)})
        For Each strLine As String In strLines
            strBody &= strLine & "<br>"
        Next

        strBody &= "<br><br>"

        Dim strFooterLines As String() = txtFooter.Text.Split(New [Char]() {CChar(vbCrLf)})
        For Each strFooterLine As String In strFooterLines
            strBody &= strFooterLine & "<br>"
        Next

        HTMLView = AlternateView.CreateAlternateViewFromString(strBody, Nothing, "text/html")

        strBody &= "</body></html>"

        subEmail(strFrom, strTo, strBcc, strSubject, strBody, boolHtml, strAddresseeEmail)
        'subEmail(strFrom, strTo, strBcc, strSubject, System.Web.HttpUtility.HtmlEncode(strBody), boolHtml, strAddresseeEmail)

    Catch ex As Exception
        Cursor = Cursors.Default
        MsgBox("An error has occurred in your application while attempting to create the email." & Chr(13) & Chr(13) & "Description: " & ex.Message & Chr(13) & Chr(13) & "Please contact your System Administrator.", MsgBoxStyle.Critical, "Application Error")
        Exit Sub
    End Try
End Sub

'Send the email
Sub subEmail(ByVal strFrom, ByVal strTo, ByVal strBcc, ByVal strSubject, ByVal strBody, ByVal bolHtml, ByVal strAddresseeEmail)
    Try
        'Dim strMailServer As String = "smtp.dsl.telkomsa.net"
        Dim strMailServer As String = "smtp.insightsa.net"
        'Dim strMailServer As String = "smtp.humeat.com"
        'Dim strMailServer As String = "mail.humeat.com"

        Dim intCount As Integer
        Dim objAttachment As Attachment

        Dim objMail As New MailMessage()
        objMail.From = New MailAddress(strFrom)
        Dim i As Integer
        Dim arrArray As Array

        arrArray = Split(strTo, ";")
        For i = 0 To arrArray.Length - 1
            objMail.To.Add(arrArray(i))
        Next

        arrArray = Split(strBcc, ";")
        For i = 0 To arrArray.Length - 1
            If Not arrArray(i) = "" Then objMail.Bcc.Add(arrArray(i))
        Next

        For intCount = 0 To lstAttachments.Items.Count - 1
            objAttachment = New Attachment(lstAttachments.Items(intCount).ToString)
            objMail.Attachments.Add(objAttachment)
        Next


        ' [TW 20110309]
        ' Create the LinkedResource (embedded image)
        Dim logo As New LinkedResource("C:\humeat.bmp")
        logo.ContentId = "Logo"

        ' [TW 20110309]
        ' Add the LinkedResource to the appropriate view
        HTMLView.LinkedResources.Add(logo)

        ' [TW 20110309]
        ' Add the views
        objMail.AlternateViews.Add(PlainView)
        objMail.AlternateViews.Add(HTMLView)

        objMail.Subject = strSubject
        objMail.Body = strBody
        objMail.IsBodyHtml = bolHtml
        Dim smtp As New SmtpClient(strMailServer)
        smtp.Port = "587" ' This is not the default port of 25 but a special smtp port because they use Mweb.  HC. 2-8-2011


        smtp.Credentials = New System.Net.NetworkCredential("humeat@insightsa.net", "123Four56")
        smtp.Send(objMail)

    Catch ex As Exception
        Cursor = Cursors.Default
        'MsgBox("An error has occurred in your application while attempting to send the email to " & strTo & "." & Chr(13) & Chr(13) & "Description: " & ex.Message & Chr(13) & Chr(13) & "Please contact your System Administrator.", MsgBoxStyle.Critical, "Application Error")
        lstEmailsNotSent.Items.Add(clsGroupCustomers.RetrieveAddressee(strAddresseeEmail, cboEmailGroup.Text) & " (" & strTo & ") - " & ex.Message)
        Exit Sub
    End Try
End Sub
4

1 に答える 1