0

The code below displays a message box with the mail subject for every incoming mail. It works well with Latin characters but fails on the Chinese ones.

The message subject is 'FW: Emailing: Copy of 小奶厅整机不同方案配置.xlsx'

But it displays the message box with following text:

New Message Received

Subject : FW: Emailing: Copy of ???????????.xlsx

Option Explicit
Private WithEvents inboxItems As Outlook.Items
Private Sub Application_Startup()
  Dim outlookApp As Outlook.Application
  Dim objectNS As Outlook.NameSpace

  Set outlookApp = Outlook.Application
  Set objectNS = outlookApp.GetNamespace("MAPI")


  Set inboxItems = objectNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub inboxItems_ItemAdd(ByVal Item As Object)
On Error GoTo ErrorHandler
Dim Msg As Outlook.MailItem
Dim MessageInfo
Dim Result
If TypeName(Item) = "MailItem" Then
        MessageInfo = "Subject : " & Item.Subject & vbCrLf
    Result = MsgBox(MessageInfo, vbOKOnly, "New Message Received")
End If
ExitNewItem:
    Exit Sub
ErrorHandler:
    MsgBox Err.Number & " - " & Err.Description
    Resume ExitNewItem
End Sub
  • You would have to make a form that looks like a message box instead. It's pretty easy to do tho. – braX Feb 08 '21 at 10:26
  • Possible duplicate of [Why does Msgbox display question marks instead of spaces that appear in text body?](https://stackoverflow.com/questions/49743685/why-does-msgbox-display-question-marks-instead-of-spaces-that-appear-in-text-bod) – niton Feb 08 '21 at 13:50

0 Answers0