API for MMS in vb.net | Search |
NowSMS Support Forums ⬆ NowSMS Support - MMS & Advanced Issues ⬆ Archive through October 14, 2015 ⬆ |
◄ ► |
Author | Message | ||||||
Michael Johns New member Username: Michaelilaga Post Number: 1 Registered: 02-2012 |
I am currently developing a vb.net application that will be able to send a MMS to phones. I am using a gprs modem and i've already tried using your web interface for MMS sending and it works fine. but I want to use that capability in my vb.net. Is there an API for that? If there is none, then how will I be able to send an MMS from my application using your service? I hope you can help me with this. By the way, the file to be attached to the MMS message will be from my local hard drive. Thanks. | ||||||
Des - NowSMS Support Board Administrator Username: Desosms Post Number: 3767 Registered: 08-2008 |
Hi Michael, I don't know VB.NET, but can you use C#.NET? Basically, the process of sending an MMS is to perform an HTTP POST using a MIME content type of multipart/form-data. This is commonly referred to as "HTTP File Upload". More information on the NowSMS specific format for this type of HTTP POST can be found here: http://www.nowsms.com/sending-mms-messages-with-nowsms Now back to C#.NET. There's a great C#.NET HTTP File Upload library at: http://aspnetupload.com/Upload-File-POST-HttpWebRequest-WebClient-RFC-1867.aspx A direct link to download the library is here (you just need UploadHelper): http://aspnetupload.com/AspNetUploadSamples.zip In case that link doesn't work in the future, here is another copy of the file:
I wrote the following sample code using that library to send an MMS message using that library: // Set the following variables as appropriate for your system. // URL that points to NowSMS web interface Uri url = new Uri("http://127.0.0.1:8800/"); // Valid username/password for account defined in NowSMS under "SMS Users". String username = "testuser"; String password = "testpass"; // Images & Files to be included in the message. // First parameter is filename and path. // Second parameter must be MMSFILE // Third parameter should be MIME type UploadFile[] files = new UploadFile[] { new UploadFile("f:\\temp\\image1.png", "MMSFILE", "image/png"), new UploadFile("f:\\temp\\image2.jpg", "MMSFILE", "image/jpeg"), }; // Create additional form parameters for sending MMS NameValueCollection form = new NameValueCollection(); // "PhoneNumber" variable contains recipient phone number form["PhoneNumber"] = "9999999999"; // "MMSFROM" variable contains sender phone number or address (Note: Ignored when sending via modem) form["MMSFROM"] = "9999999999"; // "MMSSUBJECT" variable contains subject line for message form["MMSSUBJECT"] = "test subject"; // "MMSTEXT" variable contains test to appear in message (optional) form["MMSTEXT"] = "This is a test message"; // Send the request to NowSMS, creating an HttpWebRequest and // then use HttpUploadHelper to send files in multipart/form-data format HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); var credCache = new CredentialCache(); credCache.Add(url, "Basic", new NetworkCredential(username, password)); req.Credentials = credCache; HttpWebResponse resp = HttpUploadHelper.Upload(req, files, form); // Read the HTTP response and echo to console using (Stream s = resp.GetResponseStream()) using (StreamReader sr = new StreamReader(s)) { string response = sr.ReadToEnd(); System.Console.WriteLine(response); } The discussion board software probably mangled my code a little bit, so I've also uploaded it as a text attachment.
-- Des NowSMS Support | ||||||
Michael Johns New member Username: Michaelilaga Post Number: 2 Registered: 02-2012 |
I've converted this to vb.net and it worked perfectly! thank you very much. I really appreciate your help Des! Thanks! :) | ||||||
Des - NowSMS Support Board Administrator Username: Desosms Post Number: 3768 Registered: 08-2008 |
Would you mind sharing the VB.NET conversion? (I have no idea how to convert like this...) Thanks! | ||||||
Michael Johns New member Username: Michaelilaga Post Number: 3 Registered: 02-2012 |
Here is the code in vb.net. I created a window with a single button:
These are the DLL files that I've converted from the your code. Just add references to this:
if you want the whole project I made, here is the project:
Thanks DES! | ||||||
Des - NowSMS Support Board Administrator Username: Desosms Post Number: 3772 Registered: 08-2008 |
Michael, Thanks for sharing the VB.Net translation. We've updated our examples to include that information. For others who are interested, the following links may be helpful: Send MMS Message with VB .NET Send MMS Message with C# .NET -- Des NowSMS Support | ||||||
Michael Johns New member Username: Michaelilaga Post Number: 4 Registered: 02-2012 |
When I connect two gsm modems to my laptop and try to use nowsms MMS service I get this error: "Webport already in use" How do I solve that? thanks | ||||||
Des - NowSMS Support Board Administrator Username: Desosms Post Number: 3782 Registered: 08-2008 |
I replied to your other posting on this new question: http://support.nowsms.com/discus/messages/485/70836.html | ||||||
farhan New member Username: Paan Post Number: 1 Registered: 05-2013 |
micheal john can you please mail to me the DLL file shutdefarkup@gmail.com | ||||||
Michael Johns New member Username: Michaelilaga Post Number: 11 Registered: 02-2012 |
Hi, farhan. You may just right-click on the link above for the DLL files then save the link as .rar file for you to be able to open it. | ||||||
farhan New member Username: Paan Post Number: 2 Registered: 05-2013 |
hi, Micheal how to install the DLL file in your project | ||||||
farhan New member Username: Paan Post Number: 3 Registered: 05-2013 |
where can i get these Imports ClassLibrary1 Imports ClassLibrary1.Krystalware Imports ClassLibrary1.Krystalware.UploadHelper Imports ClassLibrary1.Krystalware.UploadHelper.HttpUploadHelper Imports ClassLibrary1.Krystalware.UploadHelper.MimePart Imports ClassLibrary1.Krystalware.UploadHelper.StreamMimePart Imports ClassLibrary1.Krystalware.UploadHelper.StringMimePart Imports ClassLibrary1.Krystalware.UploadHelper.UploadFile Imports System.Collections.Specialized | ||||||
Des - NowSMS Support Board Administrator Username: Desosms Post Number: 4475 Registered: 08-2008 |
The Krystalware UploadHelper library download is referenced in the second message on this thread ... aspnetupload web site. |