Saturday 17 September 2016

HOTMAIL SEND IN VISUAL BASIC



-----------------------------------------------------------------------------------------------------------------
HOTMAIL SEND IN VISUAL BASIC WITH HIGHLIGHT CODE
COPY CODE FORM MICROSOFT WORD
http://markup.su/highlighter
http://markup.su/j/highlight.pack.js
-----------------------------------------------------------------------------------------------------------------
1) KEEP  7 TEX BOXES & ONE BUTTON
2) CLICK 7 TEXT BOX  & CHECKED MULTI TEXT OPTION
3) DOUBLE CLICK BUTTON AND PASTE BELOW CODE
-----------------------------------------------------------------------------------------------------------------

Imports System.Web
Imports System.IO
Imports System.Net.Mail

Public Class Form1

    Dim email As New MailMessage
    Dim smtp As New SmtpClient
    Dim mail As System.Net.Mail.MailAddress
    Dim Server As String = "smtp.live.com"

    Private Sub Button1_Clivk(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        email.from = New MailAddress(textbox1.text)
        email.subject = textbox3.text
        email.body = textbox7.text
        email.to.add(textbox4.text)
        smtp.EnableSsl = True
        smtp.Port = textbox5.text
        smtp.Host = textbox6.text
        smtp.Credentials = New Net.NetworkCredential(textbox1.text, textbox2.text)
        smtp.Send(email)
        MsgBox("The e-mail has been sent!")
    End Sub

End Class

-----------------------------------------------------------------------------------------------------------------
SMTP EXCEPTION WAS UNHANDLED
https://www.tutorialspoint.com/vb.net/vb.net_send_email.htm
smtp authentication exception
-----------------------------------------------------------------------------------------------------------------

Email is not sent because of failed authentication:
authentication failure [SMTP: Invalid response code received from server (code: 535, response: 5.7.8 Error: authentication failed: another step is needed in authentication)]


This error is caused 
by your SMTP server - it uses different type of authentication method.
By default plain method 
is used in our application.

You can allow on your SMTP server PLAIN authentication method or setup another authentication method in PAP4 in Configuration> Mail accounts> SMTP settings - you can choose authentication method which should be used during authentication to SMTP server (consult this with your server administrator).

To explain it more, login to SMTP server can be authenticated by methods: CRAM-MD5, DIGEST-MD5, LOGIN, PLAIN

VB.Net allows sending e-mails from your application. The System.Net.Mailnamespace contains classes used for sending e-mails to a Simple Mail Transfer Protocol (SMTP) server for delivery.
The following table lists some of these commonly used classes:
S.NClassDescription
1AttachmentRepresents an attachment to an e-mail.
2AttachmentCollectionStores attachments to be sent as part of an e-mail message.
3MailAddressRepresents the address of an electronic mail sender or recipient.
4MailAddressCollectionStores e-mail addresses that are associated with an e-mail message.
5MailMessageRepresents an e-mail message that can be sent using the SmtpClient class.
6SmtpClientAllows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP).
7SmtpExceptionRepresents the exception that is thrown when the SmtpClient is not able to complete a Send or SendAsync operation.

The SmtpClient Class

The SmtpClient class allows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP).
Following are some commonly used properties of the SmtpClient class:
S.NPropertyDescription
1ClientCertificatesSpecifies which certificates should be used to establish the Secure Sockets Layer (SSL) connection.
2CredentialsGets or sets the credentials used to authenticate the sender.
3EnableSslSpecifies whether the SmtpClient uses Secure Sockets Layer (SSL) to encrypt the connection.
4HostGets or sets the name or IP address of the host used for SMTP transactions.
5PortGets or sets the port used for SMTP transactions.
6TimeoutGets or sets a value that specifies the amount of time after which a synchronous Send call times out.
7UseDefaultCredentialsGets or sets a Boolean value that controls whether the DefaultCredentials are sent with requests.
Following are some commonly used methods of the SmtpClient class:
S.NMethod & Description
1
Dispose
Sends a QUIT message to the SMTP server, gracefully ends the TCP connection, and releases all resources used by the current instance of the SmtpClient class.
2
Dispose(Boolean)
Sends a QUIT message to the SMTP server, gracefully ends the TCP connection, releases all resources used by the current instance of the SmtpClient class, and optionally disposes of the managed resources.
3
OnSendCompleted
Raises the SendCompleted event.
4
Send(MailMessage)
Sends the specified message to an SMTP server for delivery.
5
Send(String, String, String, String)
Sends the specified e-mail message to an SMTP server for delivery. The message sender, recipients, subject, and message body are specified using String objects.
6
SendAsync(MailMessage, Object)
Sends the specified e-mail message to an SMTP server for delivery. This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes.
7
SendAsync(String, String, String, String, Object)
Sends an e-mail message to an SMTP server for delivery. The message sender, recipients, subject, and message body are specified using String objects. This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes.
8
SendAsyncCancel
Cancels an asynchronous operation to send an e-mail message.
9
SendMailAsync(MailMessage)
Sends the specified message to an SMTP server for delivery as an asynchronous operation.
10
SendMailAsync(String, String, String, String)
Sends the specified message to an SMTP server for delivery as an asynchronous operation. . The message sender, recipients, subject, and message body are specified using String objects.
11
ToString
Returns a string that represents the current object.
The following example demonstrates how to send mail using the SmtpClient class. Following points are to be noted in this respect:
  • You must specify the SMTP host server that you use to send e-mail. TheHost and Port properties will be different for different host server. We will be using gmail server.
  • You need to give the Credentials for authentication, if required by the SMTP server.
  • You should also provide the email address of the sender and the e-mail address or addresses of the recipients using the MailMessage.Fromand MailMessage.To properties, respectively.
  • You should also specify the message content using theMailMessage.Body property.

Example

In this example, let us create a simple application that would send an e-mail. Take the following steps:
  • Add three labels, three text boxes and a button control in the form.
  • Change the text properties of the labels to - 'From', 'To:' and 'Message:' respectively.
  • Change the name properties of the texts to txtFrom, txtTo and txtMessage respectively.
  • Change the text property of the button control to 'Send'
  • Add the following code in the code editor.
Imports System.Net.Mail
Public Class Form1
   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      ' Set the caption bar text of the form.   
      Me.Text = "tutorialspoint.com"
   End Sub

   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      Try
          Dim Smtp_Server As New SmtpClient
          Dim e_mail As New MailMessage()
          Smtp_Server.UseDefaultCredentials = False
          Smtp_Server.Credentials = New Net.NetworkCredential("WRITE HERE REAL GMAIL", "WRITE HERE REAL PASSWORD ")
          Smtp_Server.Port = 587
          Smtp_Server.EnableSsl = True
          Smtp_Server.Host = "smtp.gmail.com"

          e_mail = New MailMessage()
          e_mail.From = New MailAddress(txtFrom.Text)
          e_mail.To.Add(txtTo.Text)
          e_mail.Subject = "Email Sending"
          e_mail.IsBodyHtml = False
          e_mail.Body = txtMessage.Text
          Smtp_Server.Send(e_mail)
          MsgBox("Mail Sent")

      Catch error_t As Exception
          MsgBox(error_t.ToString)
      End Try

   End Sub
You must provide your gmail address and real password for credentials.
When the above code is executed and run using Start button available at the Microsoft Visual Studio tool bar, it will show the following window, which you will use to send your e-mails, try it yourself.
Sending Email from VB.Net


-----------------------------------------------------------------------------------------------------------------
FOR SMTP ERROT  HANDLED  GO INSIDE GMAIL BOX
ENABLED Enable IMAP
https://mail.google.com/mail/u/0/#settings/fwdandpop
https://www.tutorialspoint.com/vb.net/vb.net_send_email.htm
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
https://www.google.com/settings/security/lesssecureapps
https://www.youtube.com/watch?v=y3cotIr41PQ

Gmail Error: System.net.mail.SmtpException 5.5.1 Authentication Error ...


https://www.youtube.com/watch?v=y3cotIr41PQ
20 Jan 2016 - Uploaded by Living & Life
If you receive an error message when using Gmail: The SMTP server requires a secure connection or the ...


RADIO BUTTON CLICK  TURN ON
----------------------------------------------------------------------------------------------------------------





EmoticonEmoticon