dim oEmail As Outlook.mailitem
dim textbody as string
textbody = oEmail.body
msgbox textbody
Some incoming mail (foreign and domestic) contents appear fine in Outlook, but when I run the above macro program, the message box (variable textbody) shows text with question marks between words, instead of spaces.
To illustrate with example,
Outlook Mail reads:
Hello there how are you doing?
Msgbox shows:
Hello?there?how?are?you?doing?
It seems that characters are not stored properly in the variable.
The following test code results in "0" for the first instr()
, while the latter code part results in ">0". It seems the question marks in the text body prevent proper detection of consecutive matching words in the string.
if InStr(1, LCase$(textbody), "how are you") > 0 Then
msgbox "found 3 consecutive matching words in string"
end if
if InStr(1, LCase$(textbody), "how") > 0 Then
msgbox "found a word match in string"
end if