Click here to Skip to main content
12,298,927 members (49,626 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
When using the asp.net the message send to any mobile.

But i want to send the message to any mobile through my vb.net window form Application using visual studio 2005.
But all the time problem occur in sending the sms.
Please Help me.


I use the code for sending the mail is



mTo = Trim(txtPhoneNumber.Text) & Trim(cboCarrier.SelectedItem.ToString())
mFrom = Trim(txtSender.Text)
mSubject = Trim(txtSubject.Text)
mMailServer = Trim(txtMailServer.Text)
mMsg = Trim(txtMessage.Text)

Try

Dim message As New MailMessage(mFrom, mTo, mSubject, mMsg)
Dim mySmtpClient As New SmtpClient(mMailServer)
mySmtpClient.UseDefaultCredentials = True
mySmtpClient.Send(message)

MessageBox.Show("The mail message has been sent to " & message.To.ToString(), "Mail", MessageBoxButtons.OK, MessageBoxIcon.Information)

Catch ex As FormatException

MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)

Catch ex As SmtpException

MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)

Catch ex As Exception

MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try
Posted 18-Dec-12 22:01pm
ankur7891.5K

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

MailAddress mFrom = new MailAddress("your email address", "your name");
MailAddress mTo = new MailAddress("recipient mail address");
MailMessage mMessage = new MailMessage(mFrom, mTo);

mMessage.Subject = "mail subject";
mMessage.IsBodyHtml = true;

mMessage.Body = "<html><body>Hello Everybody</body></html>";

SmtpClient emailClient = new SmtpClient("Your SMTPServer");
emailClient.UseDefaultCredentials = false;

NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("SMTPUSERID", "SMTPPASSWORD");
emailClient.Credentials = SMTPUserInfo;

emailClient.EnableSsl = true_OR_false;
emailClient.Send(mMessage);
  Permalink  
Comments
ankurgupa 19-Dec-12 5:48am
   
i want to send the message at the mobile phone not at email
ankurgupa 19-Dec-12 5:48am
   
so please tell me about to send the message at a mobile phone
tiggerc 20-Dec-12 3:00am
   
you would need to look at using some form of GSM modem, and the appropriate commands, search codeproject for GSM Modem.
Using the method you are at the moment you will only be able to send an email.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 19 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100