Introduction
This VB.NET code sends Email and SMS for free with the help of your Gmail ID. One main advantage of this is that you can send SMS for free because most webservices are not free to use with your application.
Using the Code
I used Gmail as my SMTP server and Mytoday to support free SMS Service here in this code. Since this code uses Gmail SMTP server, you need a Gmail account to send Email. Actually SMS from the application is sent from the Email. You can send SMS only to particular numbers in India. When you register your phone number in the website http://email2sms.netcore.co.in/, an Email ID will be given for the phone number which you register, so that when you mail to that id the message will be received as SMS in the particular number. Suppose the phone number is 9897345890 the mail id given from that website will be like this 9897345890@m3m.in. It works only for Indian numbers.
To run this application successfully, two things should be done:
- You must have Gmail ID.
- Register the phone number which you are going to use in a website http://email2sms.netcore.co.in/.
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim smtpServer As New SmtpClient()
Dim mail As New MailMessage
smtpServer.Credentials = New Net.NetworkCredential_
(TextBox1.Text & "@gmail.com", TextBox2.Text)
smtpServer.Port = 587
smtpServer.Host = "smtp.gmail.com"
smtpServer.EnableSsl = True
mail.From = New MailAddress(TextBox1.Text & "@gmail.com")
If RadioButton1.Checked = True Then
mail.To.Add("91" & TextBox3.Text & "@m3m.in")
ElseIf RadioButton2.Checked = True Then
mail.To.Add(TextBox3.Text)
End If
mail.Subject = TextBox4.Text
mail.Body = TextBox5.Text()
smtpServer.Send(mail)
MsgBox("mail is sent", MsgBoxStyle.OkOnly, "Report")
End Sub
Hope this code will be helpful...
|
| | Msgs 1 to 13 of 13 (Total in Forum: 13) (Refresh) | FirstPrevNext |
|
 |
|
 |
hello.
he code is good.
about sms - what is the suitible code to send free sms in israel...
mail.To.Add("+972" & TextBox3.Text & "@m3m.ie")
i meed to change the code above.
please let me know...
thank you
|
|
|
|
 |
|
 |
Not a bad article but I agree with the others. The article could have been better.
Balaji - To answer how... here are some of my ideas 1. Could have made the email, port, server etc configurable so other mail servers could be used 2. Add the functionality to send SMS to any country. Not just India
|
|
|
|
 |
|
 |
So its really a poorly coded example of sending email via gmail. Its not really sending sms at all, is it?
|
|
|
|
 |
|
 |
hi i have an assignment on caculator program in vb with function to thuseday so please help me
|
|
|
|
 |
|
 |
u need calculator prog but i didnt understand "function to thuseday "...
|
|
|
|
 |
|
 |
A very poor code dump.. no suprises.
|
|
|
|
 |
|
 |
do u have any better idea on this topic...
|
|
|
|
 |
|
 |
if u ve any better idea on this topic just tell me....
|
|
|
|
 |
|
 |
I'm getting this exception while trying to send an email using my gmail credentials.
FYI : My pc is behind a proxy.
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text ************** System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 74.125.155.109:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at Email.Form1.Button1_Click(Object sender, EventArgs e) in D:\studies\my proj\Email\Email\Form1.vb:line 18 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies ************** mscorlib Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll ---------------------------------------- Email Assembly Version: 1.0.0.0 Win32 Version: 1.0.0.0 CodeBase: file:///E:/dotnet/Email%20and%20sms/Email/Email/bin/Debug/Email.exe ---------------------------------------- Microsoft.VisualBasic Assembly Version: 8.0.0.0 Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll ---------------------------------------- System Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Windows.Forms Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System.Drawing Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- System.Configuration Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Xml Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- System.Runtime.Remoting Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll ----------------------------------------
************** JIT Debugging ************** To enable just-in-time (JIT) debugging, the .config file for this application or computer (machine.config) must have the jitDebugging value set in the system.windows.forms section. The application must also be compiled with debugging enabled.
For example:
<configuration> <system.windows.forms jitDebugging="true" /> </configuration>
When JIT debugging is enabled, any unhandled exception will be sent to the JIT debugger registered on the computer rather than be handled by this dialog box.
|
|
|
|
 |
|
 |
It IS because your pc is behind a proxy.. I suggest you Push "F1" and go to the MSDN help for the smtpclient classes because the answer is so obivious i am not going to bother putting it here.. there a challenge?
|
|
|
|
 |
|
 |
and works only to indian numbers
|
|
|
|
 |
|
 |
very poor example and execution
|
|
|
|
 |
|
 |
if u ve any better idea just tell me...
|
|
|
|
 |
|
|
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+PgUp/PgDown to switch pages.