-
September 28th, 2005, 09:02 AM
#1
Unicode MAPI ****
In our app we are using MAPISendMail to send an email with an attachment. In ANSI mode everything works fine. However, once in Unicode mode it no longer works. The problem is that MapiFileDesc and MapiMessage only take LPSTR as strings. So when I have a Unicode file that is filled with Asian characters there is no way to pass that string to the MAPI stuff. Seems to me like I cannot use MAPI in this instance. Can anyone recommend another way of lauching the system's default email app and adding an attachment to it? Or if there is a way to modify the MAPI code that would work as well.
-
September 28th, 2005, 09:23 AM
#2
Re: Unicode MAPI ****
The MapiFileDesc and MapiMessage structures are taking LPTSTR, not LPSTR. LPTSTR is defined differently for Ansi (char*) and Unicode (wchat_t*)builds.
To use the unicode version you can do a:
Code:
#define UNICODE
#include <windows.h>
...
- petter
-
September 28th, 2005, 09:31 AM
#3
Re: Unicode MAPI ****
Originally Posted by wildfrog
The MapiFileDesc and MapiMessage structures are taking LPTSTR, not LPSTR. LPTSTR is defined differently for Ansi (char*) and Unicode (wchat_t*)builds.
To use the unicode version you can do a:
Code:
#define UNICODE
#include <windows.h>
...
- petter
According to MSDN it uses LPTSTR but it lies. If you look at the source it is using LPSTR not LPTSTR. That's also why in Unicode if you do try to assign a string enclosed in _T("") to say MapiFileDesc.lpszPathName it will complain about not being able to convert to a char*. If it did actually use LPTSTR I wouldn't be seeing the errors I am seeing.
-
July 23rd, 2010, 04:00 AM
#4
Re: Unicode MAPI ****
Originally Posted by ShadowCoder
According to MSDN it uses LPTSTR but it lies. If you look at the source it is using LPSTR not LPTSTR. That's also why in Unicode if you do try to assign a string enclosed in _T("") to say MapiFileDesc.lpszPathName it will complain about not being able to convert to a char*. If it did actually use LPTSTR I wouldn't be seeing the errors I am seeing.
I totally agree with you ShadowCoder. You are right. I got the same error too!
Last edited by Ming Soon; July 23rd, 2010 at 05:10 AM.
-
July 23rd, 2010, 05:15 PM
#5
Re: Unicode MAPI ****
http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
Manual says the email client may support UTF8, on Vista and later.
gg
-
July 28th, 2010, 03:01 PM
#6
Re: Unicode MAPI ****
so what would be the right solution for unicode? I am currently use MAPISendMail to launch default mail client. Though, if I attach files with unicode characters in it, it returns error MAPI_E_ATTACHMENT_OPEN_FAILURE. I am on XP. Any idea?
-
July 28th, 2010, 09:02 PM
#7
Re: Unicode MAPI ****
Did you follow the instructions for "Unicode Support" at the link I posted?
Though I would imagine that the encoding of an attached file shouldn't matter. If I attach a TXT, ZIP, DOC, etc... it just shows up as-is on the other end.
gg
-
September 3rd, 2010, 01:05 AM
#8
Re: Unicode MAPI ****
Since MapiFileDesc and MapiMessage structures said that it only take LPSTR(or in others word it is equivalent to char*).
According to your replied. We need to put in utf8. May i know how to convert a CString into utf8 and put inside LPSTR?
Example:
CString xxx;
//! TODO
LPSTR zzz;
I need xxx convert to utf8 and put it inside zzz.Any idea?
Last edited by Ming Soon; September 3rd, 2010 at 02:50 AM.
-
September 3rd, 2010, 03:32 AM
#9
Re: Unicode MAPI ****
MAPI and Unicode don't work well. There are a few clients that support the unicode version of the call. But then you'll be severely limiting your users.
The safe thing to do is to use the ANSI version, and convert any unicode filenames to the ansi equivalent. The simple way to get a valid ansi name is to get the Short (DOS) name for the file.
-
September 3rd, 2010, 03:49 AM
#10
Re: Unicode MAPI ****
Originally Posted by OReubens
MAPI and Unicode don't work well. There are a few clients that support the unicode version of the call. But then you'll be severely limiting your users.
The safe thing to do is to use the ANSI version, and convert any unicode filenames to the ansi equivalent. The simple way to get a valid ansi name is to get the Short (DOS) name for the file.
Yup, I do agree this is the safer way.Thanks . I found some guideline on how to do the conversion.
http://www.codeguru.com/forum/showthread.php?t=231165
-
September 7th, 2010, 09:07 PM
#11
Re: Unicode MAPI ****
Originally Posted by Ming Soon
I did try by using conversion guideline I found from above thread,but I notice that the Unicode will only work when your current operating system is taiwan/korean/japanese. Because the conversion type is CP_ACP.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|