Imports System
Imports System.String
Imports System.Net.Mail
Imports System.Text
Partial Class BusinessAssociates_TellAFriend
    Inherits System.Web.UI.Page
    Dim ProductId As String
    Dim enurl As String

    Protected Sub BtnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSave.Click
        email1()
        clearfields()
        CreateMessageAlert(Me, "Mail Sent Successfully.!", "strkeyval")
    End Sub
    Protected Sub clearfields()
        txtEmailId.Text = ""
        txtFEmailId.Text = ""
        txtFName.Text = ""
        txtName.Text = ""
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Session("ProductCode") <> Nothing Then
            ProductId = Session("ProductCode")
        End If
        'ProductId = Request.QueryString("Product_Id")

        'encoding the Product ID passed by previous page     
        enurl = EncodeURL(ProductId).ToString
        If Not IsPostBack Then
            btnCancel.Attributes.Add("onclick", "javascript:window.close();")
        End If
    End Sub
    Public Sub email1()
        Try
            Dim StrMail As String = ""
            Dim objmessage As New MailMessage()
            Dim sr As New SmtpClient


            'Dim k As String
            'k = Session("ProductURL").ToString

            StrMail = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">"
            StrMail = StrMail & "<html>" & "<head>" & "<meta http-equiv=""Content-Type"""
            StrMail = StrMail & "<content=""text/html""; charset=""iso-8859-1"">"
            StrMail = StrMail & "<title></title>" & "</head><body><P align=center>"
            StrMail = StrMail & "<table width='739' border='0' cellspacing='0' cellpadding='0' align='center' >"
            StrMail = StrMail & "<tr>" & "<td>"
            StrMail = StrMail & "<br>"
            StrMail = StrMail & "<br>"
            StrMail = StrMail & "<B>" & "Dear" & " " & txtFName.Text & "," & "</B>"
            StrMail = StrMail & "<br>" & "<br>"
            StrMail = StrMail & "<B>" & "I thought you might be interested in product "
            StrMail = StrMail & " " & "<font color" & "=" & "blue" & ">"
            ' StrMail = StrMail & productname
            StrMail = StrMail & "</font>" & " " & "featured on Atcomaart.com" & "</B>"
            StrMail = StrMail & "<br>"
            StrMail = StrMail & "<br>"
            StrMail = StrMail & "<B>" & "Please click on the following link to view the product" & "</B>" & "<Br>"
            'StrMail = StrMail & "<br>" & "<br>"
            StrMail = StrMail & "<B>" & "To see the specification of product details go to :" & "</B>"
            'StrMail = StrMail & "<B>" & "To see the specification of the"
            StrMail = StrMail & " " & "<font color" & "=" & "blue" & ">"
            ' StrMail = StrMail & productname
            ' StrMail = StrMail & "</font>" & " " & "," & "go to" & "</B>"
            StrMail = StrMail & "<br>"
            StrMail = StrMail & "<br>"
            StrMail = StrMail & " <a href= http://www.atcomaart.com/SearchProductDetails.aspx?ProductCode=" & enurl.ToString
            StrMail = StrMail & ">"
            StrMail = StrMail & "http://www.atcomaart.com/SearchProductDetails.aspx?ProductCode=" & enurl.ToString
            StrMail = StrMail & "</a>"
            StrMail = StrMail & "<br>" & "<br>"
            StrMail = StrMail & "<B>" & "If unable to view the page, please copy the link and paste it in a new browser window." & "</B>"
            StrMail = StrMail & "<br>" & "<br>"
            'StrMail = StrMail & "<B>" & "Please contact our product management team for any further support" & "</B>" & "<br>"
            StrMail = StrMail & "<B>" & "Please contact our product management team at " & "</B>" & " "
            StrMail = StrMail & "<SPAN>"
            StrMail = StrMail & "<A href="
            StrMail = StrMail & "mailto:contact@atcomaart.com"
            StrMail = StrMail & ">"
            StrMail = StrMail & "contact@atcomaart.com"
            StrMail = StrMail & "</A>"
            StrMail = StrMail & "</SPAN>"
            StrMail = StrMail & "<B>" & " " & "for any further support."
            StrMail = StrMail & "<br>" & "<br>"
            ' StrMail = StrMail & "<B>" & "To know more about Atcomaart please visit the link below " & "</B>" & "<br>"
            StrMail = StrMail & "<B>" & "To know more about Atcomaart ,please visit this link " & "</B>"
            StrMail = StrMail & "<a href=http://www.atcomart.com>" & "http://www.atcomart.com"
            StrMail = StrMail & "</a>"
            StrMail = StrMail & "<br>" & "<br>"
            StrMail = StrMail & "<B>" & "Best Regards :" & "</B>"
            StrMail = StrMail & "<br>" & "<B>" & txtName.Text & "</B>"
            StrMail = StrMail & "</td></tr></table></p></body></html>"


            Dim mailmsg As New MailMessage
            'From requires an instance of the MailAddress type
            mailmsg.From = New MailAddress("contact@atcomaart.com", txtEmailId.Text)
            'To is a collection of MailAddress types
            mailmsg.To.Add(New MailAddress(txtFEmailId.Text, "Atcomaart Ltd."))
            'MyMailMessage.CC.Add(New MailAddress("pankajmishra2006@gmail.com", "CC Name"))
            '    mailmsg.Bcc.Add(New MailAddress("pankaj.mishra@edeskservices.com", "eDesk Services Ltd."))
            mailmsg.Subject = "New Product Information - " & enurl.ToString
            mailmsg.Body = StrMail
            mailmsg.IsBodyHtml = True
            mailmsg.Priority = MailPriority.High
            Dim smtpsrver As New SmtpClient("smtp.rediffmailpro.com")
            smtpsrver.Credentials = New Net.NetworkCredential("contact@atcomaart.com", "traamocta")
            smtpsrver.Send(mailmsg)




            ' ''Dim fromaddr As New MailAddress(txtEmailId.Text)
            ' ''objmessage.From = fromaddr
            ' ''objmessage.Subject = "New Product Information - " & ProductId
            '' ''objmessage.From = fromaddr
            '' ''objmessage.Subject = " New Registration "
            ' ''objmessage.Body = StrMail
            ' ''objmessage.To.Add(txtFEmailId.Text)

            ' ''objmessage.IsBodyHtml = True
            ' ''sr.Host = "atcoex02"
            ' ''sr.Send(objmessage)
        Catch ex As Exception
            Dim exec As String
            exec = ex.Message.ToString
        End Try
    End Sub

  
End Class
