U
Uwe Gebhardt
Hello *,
I created a class, which allows me to send a SMS.
I used the sendSMS example from Microsoft
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/netcfSendSMS.asp)
Okay, it works fine, I can send a SMS, but only without
my own number. The receiver gets an anonymous message.
I already tried to change some options in the code, but
the SMS is still missing the number of the sender.
My code:
unsafe public bool sendSMS(string sPhoneNumber, string sMessage)
{
System.IntPtr hSms = IntPtr.Zero;
IntPtr res = SmsOpen(SMS_MSGTYPE_TEXT, (IntPtr)SMS_MODE_SEND, ref
hSms,
IntPtr.Zero);
if (res != IntPtr.Zero)
return false;
Byte[] bDest = new Byte[516];
Byte[] bDest2 = new Byte[516];
fixed (byte* pAddr = bDest)
{
fixed (byte* pAddr2 = bDest2)
{
byte *pCurrent = pAddr;
IntPtr myNumb = SmsGetPhoneNumber((IntPtr)pAddr2);
Marshal.WriteInt32((IntPtr)pCurrent, (int)AddressType.Unknown);
pCurrent +=4;
foreach (byte b in Encoding.Unicode.GetBytes(sPhoneNumber))
{
Marshal.WriteByte((IntPtr)pCurrent, b);
pCurrent++;
}
Byte[] ProvData = new Byte[12];
byte[] bMessage = Encoding.Unicode.GetBytes(sMessage);
int nMsgSize = bMessage.Length;
res = SmsSendMessage(hSms, myNumb, (IntPtr)pAddr, IntPtr.Zero,
bMessage, (IntPtr)nMsgSize, ProvData, (IntPtr)ProvData.Length,
SMS_DATA_ENCODING.SMSDE_GSM, (IntPtr)SMS_OPTION_DELIVERY_NONE,
IntPtr.Zero);
if (res != IntPtr.Zero)
return false;
SmsClose(hSms);
return true;
}
}
}
Any ideas, what I'm doing wrong?
I created a class, which allows me to send a SMS.
I used the sendSMS example from Microsoft
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/netcfSendSMS.asp)
Okay, it works fine, I can send a SMS, but only without
my own number. The receiver gets an anonymous message.
I already tried to change some options in the code, but
the SMS is still missing the number of the sender.
My code:
unsafe public bool sendSMS(string sPhoneNumber, string sMessage)
{
System.IntPtr hSms = IntPtr.Zero;
IntPtr res = SmsOpen(SMS_MSGTYPE_TEXT, (IntPtr)SMS_MODE_SEND, ref
hSms,
IntPtr.Zero);
if (res != IntPtr.Zero)
return false;
Byte[] bDest = new Byte[516];
Byte[] bDest2 = new Byte[516];
fixed (byte* pAddr = bDest)
{
fixed (byte* pAddr2 = bDest2)
{
byte *pCurrent = pAddr;
IntPtr myNumb = SmsGetPhoneNumber((IntPtr)pAddr2);
Marshal.WriteInt32((IntPtr)pCurrent, (int)AddressType.Unknown);
pCurrent +=4;
foreach (byte b in Encoding.Unicode.GetBytes(sPhoneNumber))
{
Marshal.WriteByte((IntPtr)pCurrent, b);
pCurrent++;
}
Byte[] ProvData = new Byte[12];
byte[] bMessage = Encoding.Unicode.GetBytes(sMessage);
int nMsgSize = bMessage.Length;
res = SmsSendMessage(hSms, myNumb, (IntPtr)pAddr, IntPtr.Zero,
bMessage, (IntPtr)nMsgSize, ProvData, (IntPtr)ProvData.Length,
SMS_DATA_ENCODING.SMSDE_GSM, (IntPtr)SMS_OPTION_DELIVERY_NONE,
IntPtr.Zero);
if (res != IntPtr.Zero)
return false;
SmsClose(hSms);
return true;
}
}
}
Any ideas, what I'm doing wrong?