Send up arrow `↑` character to iPhone with SMS usi

2020-02-13 13:02发布

I need to send an up arrow to an iPhone with SMS using VBA and a CDO mail object.

My attempts are as follows:

Unicode:

subj =  ChrW(8593) & " Up " & ChrW(8593)

HTML:

subj =  "↑ Up ↑"

Both of the above methods result in the iPhone receiving either a ? Up ? for the Unicode or ↑ Up ↑ as a string literal.

Does anyone know the correct syntax for an up arrow ?

1条回答
等我变得足够好
2楼-- · 2020-02-13 13:42

Solution:

I was looking for some 'special character' syntax but the problem was not in the construction of the message. I needed to add .BodyPart.Charset = "utf-8" to the CDO.Message object and use the Unicode Chrw(8593) where I needed it.

Sub sendMSSG(sbj As String, mssg As String)
    Dim cdoMail As New CDO.Message
    On Error GoTo err_Report

    With cdoMail
        With .Configuration.Fields
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort '2
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "my.smtpserverserver.net"
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic  '1
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = sFROM
            .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = sFROMPWD
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 6
            .Update
        End With
        .BodyPart.Charset = "utf-8"     '<~~ THIS WAS REQUIRED
        .Subject = sbj
        .From = sFROM
        .To = sPHONEMSSGNO
        .Bcc = vbNullString
        .Cc = vbNullString
        .TextBody = mssg
        .Send
    End With

    Exit Sub

err_Report:
    Debug.Print Err.Number & ": " & Err.Description

End Sub

Apparently, .BodyPart.Charset covers both the subject and the message body as I was able to use unicode in both.


Anyone planning to use this code for their own purposes needs to add the Microsoft CDO for Windows 2000 library to their project via Tools, References.

查看更多
登录 后发表回答