Closed Bug 611081 Opened 14 years ago Closed 5 years ago

UTF-8 support for Simple MAPI

Categories

(MailNews Core :: Simple MAPI, enhancement)

x86
Windows 7
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1521007

People

(Reporter: bugzilla, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101027 Lightning/1.0b2 Thunderbird/3.1.6

As far as I know, most email clients other than Outlook only support Simple MAPI. Simple MAPI only supports ASCII, and while there is a MAPI_UNICODE flag, it is only available for extended MAPI, and cannot be used with Simple MAPI, so there was generally no way to get Unicode characters into a new message window using MAPI.

There is a flag that is short on documentation, but appears at the bottom of http://msdn.microsoft.com/en-us/library/dd296721%28VS.85%29.aspx mentioning a way (as of Vista) to expose that a mail app's Simple MAPI interface supports UTF-8.

This mentions that apps should "set the MapiMessage::ulReserved flag to CP_UTF8" but it does not appear that Thunderbird checks for CP_UTF8.

This bug is to add this feature to Thunderbird, so that a Unicode compiled (UTF-16) Windows app can create a UTF-8 message in Thunderbird. Right now, Thunderbird has no way to do this.

Reproducible: Always

Steps to Reproduce:
LHANDLE hSess = NULL;
MAPILogon(0, NULL, NULL, MAPI_LOGON_UI, 0, &hSess);

MapiMessage msg;
ZeroMemory(&msg, sizeof(msg));
msg.ulReserved = CP_UTF8; //this is the magic flag that needs support!
msg.lpszSubject = "\xC3\xA9\xC3\xB1 x \xD0\xB8\xD1\x8F x \xE5\x93\x81"; //some UTF-8 encoded test string
MAPISendMail(hSess, 0, &msg, MAPI_DIALOG, 0);

MAPILogoff(hSess, 0, 0, 0);
Actual Results:  
Write Mail window appears with Subject "éñ x Ð¸Ñ x å“"

(windows-1252 representation of the UTF-8 string)

Expected Results:  
Write Mail window appears with Subject "éñ x ия x 品"

(UTF-16 string L"\u00E9\u00F1 x \u0438\u044F x \u54C1")
In mailnews/mapi/mapihook/src/msgMapiImp.cpp CMapiImp::SendMail() it looks like the MAPI_UNICODE flag is checked, but Simple MAPI does not allow for this flag, and even Outlook 2007 will ignore the call if you specify this flag, so I'm not sure why that line exists.

Anyway, into mailnews/mapi/mapihook/src/msgMapiHook.cpp nsMapiHook::PopulateCompFieldsWithConversion() is where I think the check for aMessage->ulReserved == CP_UTF8 should happen.
All fields (To, From, Subject, Body, Attachment file name and disk name) should be converted using UTF-8 instead of "platformCharSet"

Alternatively, CMapiImp::SendMail() could have a check for aMessage->ulReserved == CP_UTF8 after the aFlags & MAPI_UNICODE check, and call a new function like rv = nsMapiHook::PopulateCompFieldsWithUTF8Conversion(aMessage, pCompFields) ;
Component: OS Integration → Simple MAPI
Product: Thunderbird → MailNews Core
QA Contact: os-integration → simple-mapi
Attached patch Shot in the darkSplinter Review
Will it even compile? Who knows. Probably not.
Removing myslef on all the bugs I'm cced on. Please NI me if you need something on MailNews Core bugs from me.
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE

This isn't a duplicate of bug 1048658; it's a duplicate of bug 1521007.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: