Basic grammars for vb.net

1 minute read

#Region "Your comments here"
    ' Your codes are here
#End Region

How to send email

    ''' <summary>
    ''' Initialize password and send email
    ''' </summary>
    ''' <param name="email_addr"></param>
    ''' <param name="app_name"></param>
    ''' <param name="new_pass"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function SendEmail(ByVal email_addr As String, ByVal app_name As String, ByVal new_pass As String) As Boolean

        Dim subject As String = "Password was reset"
        Dim content As String = ""
        content += "Hello " + email_addr
        content += vbCrLf + vbCrLf
        content += app_name + " Initial password is " + new_pass
        content += vbCrLf + vbCrLf
        content += "Thank you."
        content += vbCrLf + vbCrLf
        content += "StudioExitt"

        Dim mail_sender As String = "noreply@yourweb.net"
        Dim smtp_domain As String = "mail.yourweb.net"
        Dim mail_passwd As String = "exit_noreply"

        ' Send email
        Try
            Dim msg As MailMessage = New MailMessage(mail_sender, email_addr, subject, content)
            Dim smtp As SmtpClient = New SmtpClient(smtp_domain, 587)
            smtp.EnableSsl = False
            smtp.Credentials = New NetworkCredential(mail_sender, mail_passwd)
            smtp.Send(msg)
        Catch ex As Exception
            Return False
        End Try

        Return True

    End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim JSON_DAT = ""
    Dim JSON_OBJ As JObject = Nothing

    Dim MSG_TYPE As String = ""
    Dim INIT_EMAIL As String = ""
    Dim INIT_APP As String = ""

    '''''''''''''''''''''''''''''''''
    ' GET parameters
    '''''''''''''''''''''''''''''''''
    For Each tags As String In Request.QueryString
        If tags = "initEmail" Then
            INIT_EMAIL = Request.QueryString(tags)
        ElseIf tags = "initApp" Then
            INIT_APP = Request.QueryString(tags)
        ElseIf tags = "msgType" Then
            MSG_TYPE = Request.QueryString(tags)
        End If
            'Response.Write(Str + " = " + Request.QueryString(Str))
    Next

End Sub
If JSON_OBJ IsNot Nothing Then
    If MSG_TYPE = "SHAREU" Then
        Dim rtn = InsertSHARE_CONTENTS(JSON_OBJ)
        Response.Write(rtn)
    Else
        'msgType is not defined
        Response.Write("Result: msgType mismatch")
        'Response.Write(JSON_OBJ.ToString()) 'Just for debugging
        Exit Sub
    End If
End If

Tags:

Categories:

Updated:

Leave a comment