Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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);
 
Share this answer
 
Comments
ankur789 19-Dec-12 5:48am    
i want to send the message at the mobile phone not at email
ankur789 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900