Tuesday, January 12, 2016

Why write their own smartphone program to send text messages, send Chinese would be a distortion?




            


Code is as follows:

ICEMAPISession * mapiSession = NULL;
IMAPITable * msgTable = NULL;
IMsgStore * msgStore = NULL;
LPMAPITABLE pTable = NULL;
SRowSet * pRows = NULL;


HRESULT hr;



if (MAPILogonEx (0, NULL, NULL, 0, (LPMAPISESSION *) & amp;! mapiSession) = S_OK)
{
MessageBox (_T ("Failed to logon"), _ T ("Error"));
}
else
{
SizedSPropTagArray (2, PropTagArr) = {2, {PR_DISPLAY_NAME, PR_ENTRYID}};
hr = mapiSession- & gt; GetMsgStoresTable (MAPI_UNICODE, & amp; msgTable);
hr = msgTable- & gt; SetColumns ((LPSPropTagArray) & amp; PropTagArr, 0);
if (! hr)
{
do
{
hr = msgTable- & gt; QueryRows (1,0, & amp; pRows);
LPSPropValue lpProp;
lpProp = & amp; pRows- & gt; aRow [0] .lpProps [0];

if (_tcscmp (lpProp- & gt; Value.LPSZ, _T ("SMS")) == 0)
{
break;

}
FreeProws (pRows);
pRows = NULL;
} While (hr!);
}
hr = mapiSession- & gt; OpenMsgStore (0,
pRows- & gt; aRow [0] .lpProps [1] .Value.bin.cb,
(ENTRYID *) pRows- & gt; aRow [0] .lpProps [1] .Value.bin.lpb,
NULL, MDB_NO_DIALOG | MAPI_BEST_ACCESS,
& Amp; msgStore);
////////////////////////////////////////////////// ////////////
IMAPIFolder * pFolder;
LPSPropValue rgprops = NULL;
SizedSPropTagArray (1, rgTags) = {1, {PR_CE_IPM_DRAFTS_ENTRYID}}; // PR_CE_IPM_DRAFTS_ENTRYID PR_CE_IPM_INBOX_ENTRYID
ULONG ulValues = 0;
int nMsg = 0;
msgStore- & gt; GetProps ((LPSPropTagArray) & amp; rgTags, MAPI_UNICODE, & amp; ulValues, & amp; rgprops);
hr = msgStore- & gt; OpenEntry (rgprops [0] .Value.bin.cb, (LPENTRYID) rgprops [0] .Value.bin.lpb, NULL, MAPI_MODIFY, NULL, (LPUNKNOWN *) & amp; pFolder);



LPMESSAGE lpMsg = NULL;

SPropValue Data [3];
TCHAR szNum [12];
char szBody [80];
TCHAR * pszSubjectW = NULL;


hr = pFolder- & gt; CreateMessage (NULL, 0, & amp; lpMsg);


swprintf (szNum, _T ("13560185253"));
sprintf (szBody, "Why not ~?");
pszSubjectW = ToUTF8 (szBody);
Data [0] .ulPropTag = PR_SUBJECT;
Data [0] .Value.lpszW = pszSubjectW; //
Data [1] .ulPropTag = PR_MSG_STATUS;
Data [1] .Value.ul = MSGSTATUS_RECTYPE_SMS; // _ T ("13286873736");
Data [2] .ulPropTag = PR_MESSAGE_FLAGS;
Data [2] .Value.ul = MSGFLAG_UNSENT | MSGFLAG_FROMME;



hr = lpMsg- & gt; SetProps (sizeof (Data) / sizeof (Data [0]), (LPSPropValue) Data, NULL);

///
ADRLIST adrList;
SPropValue val [3];

ZeroMemory (& amp; val, sizeof (val));

adrList.cEntries = 1;

adrList.aEntries [0] .cValues = 3;

adrList.aEntries [0] .rgPropVals = val;

val [0] .ulPropTag = PR_EMAIL_ADDRESS;

val [0] .Value.lpszW = szNum;

val [1] .ulPropTag = PR_DISPLAY_NAME;

val [1] .Value.lpszW = _T ("");

val [2] .ulPropTag = PR_ADDRTYPE;

val [2] .Value.lpszW = _T ("SMS");

lpMsg- & gt; ModifyRecipients (MODRECIP_ADD, & amp; adrList);



if (lpMsg- & gt; SubmitMessage (0) == S_OK)
{
MessageBox (_T ("sent successfully ~"), _ T ("Tip:"), MB_OK);
}
else
{
MessageBox (_T ("Send failed ~"), _ T ("Tip:"), MB_OK);
}





lpMsg- & gt; Release ();

if (pszSubjectW! = NULL)
{
delete [] pszSubjectW;
}





:: ReleaseDC (m_hWnd, hdc);
pFolder- & gt; Release ();
msgStore- & gt; Release ();


Send English normal, but send Chinese, will be received at the other ????

Who knows what it ~

Reply:
Nobody come oh ....
Reply:
Top points
Reply:
I want to convert it, use pdu mode
Reply:
Your BODY use UTF8! UTF8 is the direct display "????" look, to turn into UNICODE.
Reply:
Collect
Reply:
Write to find the reason ~
Tried the UNICODE ~



Reply:
The reply is deleted moderator

Reply:
The sender really use UNICODE? LOG receiving end that can play out it? Then written to a file can take a look. In addition, there will not be a problem to display it, check. I wrote a long time ago, received and made no such problems.
Reply:
Invent, turn what pdu ah, as long as the first save as a unicode message on it.
Reply:
Collect
Reply:
Go to my blog to see to know

CEMAPI send SMS garbled solution
http://blog.csdn.net/luandao2000
Reply:
Encoding problem
Reply:
szBody directly defined as TCHAR, do not use the back of the transformation. Should
possible.
Reply:
For send Chinese SMS, there is a secret trick. It is the content of the message you want to apply for a relatively long string. Last time I tried. As TCHAR szSubject [5050]; if equal 5050, an error message will be greater than 5050 you can see the Chinese, and less than 5050 Chinese characters on programmed ???? number.
Reply:
The problem with all CEMAPI send SMS comrades will encounter the fundamental problem lies in the content of sms are not saved when you save in accordance with unicode type. Set to unicode type to get.

Code is as follows:
IMAPIFolder * pCurFolder = GetMsgFolder (ID_DRAFTS);

SPropValue Data [3];
SPropValue propVals [1];

MAPINAMEID mapiNameId;
ZeroMemory (& amp; mapiNameId, sizeof (mapiNameId));
GUID PS_MAPI = {0x00020328, 0, 0, 0xC0,0,0,0,0,0,0,0x46};
mapiNameId.lpguid = (LPGUID) & amp; PS_MAPI;
mapiNameId.ulKind = MNID_STRING;
mapiNameId.Kind.lpwstrName = L "SMS: Unicode";
LPMAPINAMEID pmapiNameId = & amp; mapiNameId;
LPSPropTagArray psPropArr = NULL;

hr = pCurFolder- & gt; CreateMessage (NULL, 0, & amp; pMessage);
if (FAILED (hr))
goto Exit;


hr = pMessage- & gt; GetIDsFromNames (1, & amp; pmapiNameId, MAPI_CREATE, & amp; psPropArr);
if (FAILED (hr))
{
if (NULL! = psPropArr)
{
MAPIFreeBuffer (psPropArr);
psPropArr = NULL;
}
pMessage- & gt; Release ();
pCurFolder- & gt; Release ();
return hr;
}
if (NULL! = psPropArr)
{
propVals [0] .ulPropTag = CHANGE_PROP_TYPE (psPropArr [0] .aulPropTag [0], PT_BOOLEAN);
propVals [0] .Value.b = TRUE;
hr = pMessage- & gt; SetProps (1, propVals, NULL);
ASSERT (SUCCEEDED (hr));
if (FAILED (hr))
{
MAPIFreeBuffer (psPropArr);
psPropArr = NULL;
pMessage- & gt; Release ();
pCurFolder- & gt; Release ();
return hr;
}
MAPIFreeBuffer (psPropArr);
}


//Data[0].ulPropTag = PR_SUBJECT;
//Data[0].Value.lpszW = PSms- & gt; szSubject;


Data [0] .ulPropTag = PR_SUBJECT;
Data [0] .Value.lpszW = pSms- & gt; szSubject;


Data [1] .ulPropTag = PR_MSG_STATUS;
Data [1] .Value.ul = MSGSTATUS_RECTYPE_SMS;

Data [2] .ulPropTag = PR_MESSAGE_FLAGS;
Data [2] .Value.ul = MSGFLAG_UNSENT | MSGFLAG_FROMME;

pMessage- & gt; SetProps (sizeof (Data) / sizeof (Data [0]), (LPSPropValue) Data, NULL);

SetMsgRecipient (pMessage, pSms);

hr = pMessage- & gt; SubmitMessage (0);




Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1667751

No comments:

Post a Comment