Sending MMS in C# always fail

Sending MMS in C# always fail SearchSearch
Author Message
qingjun
New member
Username: Qingjuntian

Post Number: 1
Registered: 10-2014
Posted on Wednesday, October 22, 2014 - 04:31 am:   

hi there,

here is my sending Code:
"
WinHttp.WinHttpRequestClass mms = new WinHttp.WinHttpRequestClass();
mms.Open("Post", host, false);
mms.SetRequestHeader("HTTP_CONTENT_TYPE", header);
mms.Send(sendImage);
"
Here the header is "multipart/form-data; boundary=---------------------------7de3b31e1a0752", the data should be correct formatted with this content type;
The host parameter here i am using is "semcw16113:9000";

Unfortunately the mms can not be delivered...

here is my mmsc.ini file:
"
[MMSC]
WebPort=9000
HostName=semcw16113
SMTPPort=25
SMTPRequireAuth=No
EnableDeliveryNotification=No
ConvertImages=Yes
ConvertScaleToScreen=Yes
DefaultOutboundRoute=mms_test
Debug=Yes
"

I can send mms thru the web portal "semcw16113:8800". and i can also send sms via c# with the host "semcw16113:8800".

I enabled the mms log and it reads as below:
"
10:38:08:577 [14] InternalProcessConnection: Thread started
10:38:10:587 [14] ThreadProcessConnection: Processing connection from 10.147.8.78...
10:38:10:588 [14] ThreadProcessConnection: C:\ProgramData\NowSMS\MMSCDATA\.INI
10:38:10:589 [14] ThreadProcessConnection: File not found
10:38:10:589 [14] ThreadProcessConnection: C:\ProgramData\NowSMS\MMSCDATA\
10:38:10:589 [14] ThreadProcessConnection: HTTP/1.1 404 Not Found
Content-Length: 0
Connection: Keep-Alive
10:38:18:427 [14] ProcessRead: Winsock:ioctlsocket reports end of socket
10:38:18:427 [14] ThreadProcessConnection: Processing Complete
10:38:18:427 [14] WaitForSocketClose: WinSock reported ioctlsocket complete
10:38:18:427 [14] InternalProcessConnection: Thread ended
"

I will be appreciate for any indicates and help!

Qingjun
qingjun
New member
Username: Qingjuntian

Post Number: 2
Registered: 10-2014
Posted on Wednesday, October 22, 2014 - 07:11 am:   

my mms outbound routing
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5086
Registered: 08-2008
Posted on Wednesday, October 22, 2014 - 07:46 pm:   

Hi,

I assume you can send MMS oK with the NowSMS web interface form, correct?

The MMSCDEBUG.LOG looks like an HTTP GET request is being received instead of HTTP POST.

Try adding DebugFull=Yes to the [MMSC] section of MMSC.INI and it should display a full hex dump of the HTTP request received.

Have you tried the code here: http://www.nowsms.com/doc/submitting-mms-messages/send-mms-message-with-c-net

It can be tricky to do a multipart/form-data upload ... that example is a few years old ... at the time we looked at it, we had to use a 3rd party library to format the multipart POST.


--
Des
NowSMS Support
qingjun
New member
Username: Qingjuntian

Post Number: 3
Registered: 10-2014
Posted on Thursday, October 23, 2014 - 06:16 am:   

hi Des,

Yes you are right I can send MMS with the web interface.

I enabled the DebugFull and the log looks like
application/octet-stream
MMSCDEBUG.LOG (41.8 k)


I also tried the same method with the httpUploadHelper, but it does not work...here is my code:
"
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://semcw16113/8800"); //"http://semcw16113/9000"
req.ContentType = "multipart/form-data; boundary=---------------------------7de3b31e1a0752";
req.Method = "POST";
using (Stream s = req.GetRequestStream())
{
s.Write(sendImage, 0, sendImage.Length);
}
string respStr;
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
using (Stream s = resp.GetResponseStream())
using (StreamReader sr = new StreamReader(s))
{
respStr = sr.ReadToEnd();
}
}
catch (WebException wex)
{
StreamReader reader = new StreamReader(wex.Response.GetResponseStream());
string result = reader.ReadToEnd();
}
"

I read this post "http://support.nowsms.com/discus/messages/485/6557.html", seems i should use port 8800.
- If I try 8800, no exception happened but device can not receive mms;
- If I try 9000, there is something shown in the MMSCDEBUG.LOG, and i got "Unknown request: content type is unknown" error...fail again.

Please help me out...

Qingjun
qingjun
New member
Username: Qingjuntian

Post Number: 4
Registered: 10-2014
Posted on Thursday, October 23, 2014 - 06:30 am:   

Hi again,

I enabled Sms Gateway, and here is the log.

application/octet-stream
SMSDEBUG.LOG (4.1 k)
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5090
Registered: 08-2008
Posted on Thursday, October 23, 2014 - 07:35 pm:   

Hi Qingjun,

There appear to be multiple issues.

The first (and most critical) is that HTTP_CONTENT_TYPE should be Content-Type

Another problem is the variable names for the data elements. In the debug log I see variables like this:

name="ctl00$ContentPlaceHolder1$MMSText"

But it should be:

name="MMSText"

--
Des
NowSMS Support