Friday, 21 April 2017

Email

 Public Sub mail()
        Dim FromAddress As String = Nothing
        Dim ToAddress As String = Nothing
        Dim CCAddress As String = Nothing
        Dim BCCAddress As String = Nothing
        Dim PartyToAddress As String = Nothing
        Dim PartyCCAddress As String = Nothing

        'MailSend = 0

        Dim Subject As String = ""
        Dim BodyText As String

        Subject = "Test Mail"

        BodyText = ""
        BodyText = " Dear Sir,  " + vbCrLf + vbCrLf _
        + " Test" + vbCrLf + vbCrLf

        FromAddress = "pppp@kkkk.com"
        Dim SendFrom As MailAddress = New MailAddress(FromAddress)
        ToAddress = "pppp@kkkk.com"
        Dim SendTo As MailAddress = New MailAddress(ToAddress)

        Dim mailInstance As MailMessage

        Dim mailSenderInstance As SmtpClient = New SmtpClient("192.168.100.7", 25) '25 is the port of the SMTP host

        mailSenderInstance.Credentials = New System.Net.NetworkCredential("hh", "hh")

        mailInstance = New MailMessage(FromAddress, ToAddress, Subject, BodyText)
        ' mailInstance.CC.Add(CCAddress)

        mailInstance.Priority = MailPriority.High

        mailSenderInstance.Send(mailInstance)

        mailInstance.Attachments.Dispose()
        mailInstance.Dispose() 'Please remember to dispose this object

        MsgBox("Mail Has Been Send Successfully ")
    End Sub

No comments:

Post a Comment