SendText Method--------------------------------------------------------------------------------The SendText method sends an Instant Message to all members of the session.Applies ToIIMSession Interface Type LibraryMSIM Control 1.0 Type Library DLL Implemented InMSIMCntl.dll Syntax[Visual Basic]Function SendText( bstrMsgHeader As String, bstrMsgText As String, MsgType As IM_MSG_TYPE) As LONG[C++]HRESULT SendText ( BSTR bstrMsgHeader, BSTR bstrMsgText, IM_MSG_TYPE MsgType, LONG* plCookie );ParametersbstrMsgHeader A header that contains Multipurpose Internet Mail Extensions (MIME) information for the message that is contained in bstrMsgText. bstrMsgText A string containing the text of the message. MsgType A value from the IM_MSG_TYPE Enum. plCookie A pointer to a unique numerical identifier that correlates this message to notifications sent in response to the message. Return ValueReturns S_OK if successful, or an error value otherwise. ResThe bstrMsgHeader must be formatted as follows: "MIME-Version: 1.0" "Content-Type: text/plain"Note the trailing extra return (CR) character. The following additional MIME types are also supported. Substitute these MIME strings in the example above: "Content-Type: text/plain; charset=UTF-8" "Content-Type: text/html" "Content-Type: text/html; charset=UTF-8" The following is an example of the valid header string: CComBSTR MyHeader = "MIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\n"
觉得不能用UTF-8,但不知道用什么,Unicode?
试试看不用utf-8行不行,用其他的 顶
用HTML转码工具将你的消息先转码试试
string s = "中文"; 发送要转编码及转成字节数组byte[]. 可用 System.Text 下类转换,应该可解决乱码的问题。
System.IO.FileStream filestream = System.IO.File.OpenRead(node.strEDIName ); byte[] b = new byte[filestream.Length]; filestream.Read( b , 0 , b.Length ); filestream.Close();... nRet = commSmtp.MailSendMsg( commEDIHeader , b ); ..... 上面为从一个文件中读取内容,并把内容发送出去例子,这样以字节数组形式发出去就可解决乱码问题,你可以试试。
Type LibraryMSIM Control 1.0 Type Library
DLL Implemented InMSIMCntl.dll
Syntax[Visual Basic]Function SendText( bstrMsgHeader As String,
bstrMsgText As String,
MsgType As IM_MSG_TYPE) As LONG[C++]HRESULT SendText
(
BSTR bstrMsgHeader,
BSTR bstrMsgText,
IM_MSG_TYPE MsgType,
LONG* plCookie
);ParametersbstrMsgHeader
A header that contains Multipurpose Internet Mail Extensions (MIME) information for the message that is contained in bstrMsgText.
bstrMsgText
A string containing the text of the message.
MsgType
A value from the IM_MSG_TYPE Enum.
plCookie
A pointer to a unique numerical identifier that correlates this message to notifications sent in response to the message.
Return ValueReturns S_OK if successful, or an error value otherwise.
ResThe bstrMsgHeader must be formatted as follows:
"MIME-Version: 1.0"
"Content-Type: text/plain"Note the trailing extra return (CR) character. The following additional MIME types are also supported. Substitute these MIME strings in the example above:
"Content-Type: text/plain; charset=UTF-8"
"Content-Type: text/html"
"Content-Type: text/html; charset=UTF-8"
The following is an example of the valid header string:
CComBSTR MyHeader = "MIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\n"
顶
发送要转编码及转成字节数组byte[].
可用 System.Text 下类转换,应该可解决乱码的问题。
byte[] b = new byte[filestream.Length];
filestream.Read( b , 0 , b.Length );
filestream.Close();...
nRet = commSmtp.MailSendMsg( commEDIHeader , b );
..... 上面为从一个文件中读取内容,并把内容发送出去例子,这样以字节数组形式发出去就可解决乱码问题,你可以试试。
sendtext方法的第二个参数是字符串,不是byte[]
,另外各种方式的转码过后生成的字符串,比如e9e89w99什么的都会按原样输出。
如果是普通文本,就要转换为base64,并且在head中表示出来是base64的编码,客户端就没有问题了