LONG GetText( |
|
LPTSTR lpszBuffer, |
|
|
LONG nMaxLength, |
|
|
LONG nOffset |
|
); |
LONG GetText( |
|
CString& strBuffer, |
|
|
LONG nOffset |
|
); |
The GetText method copies the text of the current message
part to the specified buffer.
Parameters
- lpszBuffer
- A pointer to a string buffer that will receive a copy of the
message text when the method returns.
- nMaxLength
- The maximum number of bytes to copy into the buffer. The size of
the buffer provided must be larger than the content length for the
current message part.
- nOffset
- The byte offset from the beginning of the message. A value of
zero specifies the first character in the body of the message
part.
Return Value
If the method succeeds, the return value is number of bytes copied
into the buffer. If the method fails, the return value is MIME_ERROR.
To get extended error information, call GetLastError.
Remarks
If your project targets a multi-byte character set,
this method will always return the message contents as UTF-8 text,
regardless of the original character set specified in the message
itself. This ensures that characters in the original text are
preserved, regardless of the default ANSI code page on the local
system. It is recommended you build your project to use Unicode
whenever possible. If your application must use ANSI, you can use the
LocalizeText method to convert the Unicode text to a
specific character set.
You should not determine the maximum size of the output buffer
using the GetContentLength method. That method
returns the content size in bytes as it is stored in the message, and
does not account for any character encoding or Unicode conversion
which may be required. The content length can be used to estimate the
amount of text stored in the message part, but you should always
allocate a buffer which is larger than the length specified in the
message.
If the nMaxLength parameter does not specify a buffer size
large enough to store the contents of the current message part, this
method will fail and the last error code will be set to
ST_ERROR_BUFFER_TOO_SMALL. Your application must ensure the buffer is
large enough to contain the complete message text and a terminating
NUL character.
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csmsgv10.lib
Unicode: Implemented as Unicode and ANSI versions.
See Also
AppendText,
ClearText,
CompareText,
ExportMessage,
GetContentLength,
ImportMessage,
LocalizeText,
SetText
|