Imports CharterDotCom.CommonEntities.Library
Imports CharterDotCom.CommonEntities.Library.Common
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.CommonEntities.Library.EntityMemberServices
Imports CharterDotCom.CommonEntities.Library.EntityEBSServices
Imports CharterDotCom.CommonEntities.Library.EntitySupport
Imports CharterDotCom.CommonEntities.Library.EntitySearch
Imports CharterDotCom.CommonEntities.Library.EntityWebConfig
Imports CharterDotCom.CommonEntities.Library.EntityG2BServices
Imports CharterDotCom.WebSite.Library
Imports CharterDotCom.WebSite.Library.BLCommon
Imports System.IO


Partial Class Visitors_CampaignLanding_SendToFriend
    Inherits CharterCMSPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            SetPageTitle("Refer a Friend Page")

            'Dim sr As New StreamReader(Request.InputStream)
            'Dim str As String = sr.ReadToEnd()

            Dim blnSendEmail As Boolean = False
            Dim sbEmailBody As New StringBuilder()

            Dim sender_name As String = "Not Provided"
            Dim sender_email As String = "Not Provided"
            Dim recipient_name As String = "Not Provided"
            Dim recipient_email As String = "Not Provided"
            Dim comments As String = "Not Provided"

            


            If Not (Request.Form("fromName") Is Nothing) Then
                If (Request.Form("fromName").Trim() <> String.Empty) Then
                    sender_name = Request.Form("fromName")
                    sender_name = sender_name.Trim()
                    blnSendEmail = True
                End If
            End If
            If Not (Request.Form("fromEmail") Is Nothing) Then
                If (Request.Form("fromEmail").Trim() <> String.Empty) Then
                    sender_email = Request.Form("fromEmail")
                    sender_email = sender_email.Trim()
                    blnSendEmail = True
                End If
            End If
            If Not (Request.Form("toName") Is Nothing) Then
                If (Request.Form("toName").Trim() <> String.Empty) Then
                    recipient_name = Request.Form("toName")
                    recipient_name = recipient_name.Trim()
                    blnSendEmail = True
                End If
            End If
            If Not (Request.Form("toEmail") Is Nothing) Then
                If (Request.Form("toEmail").Trim() <> String.Empty) Then
                    recipient_email = Request.Form("toEmail")
                    recipient_email = recipient_email.Trim()
                    blnSendEmail = True
                End If
            End If
            If Not (Request.Form("Message2") Is Nothing) Then
                If (Request.Form("Message2").Trim() <> String.Empty) Then
                    comments = Request.Form("Message2")
                    comments = comments.Trim()
                    blnSendEmail = True
                End If
            End If

            If blnSendEmail Then
                'sbEmailBody.Append("<table style=""FONT-SIZE: 12px; COLOR: #666666; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif"" cellspacing=""0"" width=""85%"" align=""center"" bgcolor=""#ffffff"" border=""0"">" & vbNewLine)
                'sbEmailBody.Append("    <tbody>" & vbNewLine)
                'sbEmailBody.Append("        <tr>" & vbNewLine)
                'sbEmailBody.Append("            <td style=""BORDER-BOTTOM: #666666 1px solid""><img height=""64"" alt=""Charter Communications"" width=""164"" border=""0"" src=""http://connect.charter.com/images/charter_logo.gif"" /> </td>" & vbNewLine)
                'sbEmailBody.Append("        </tr>" & vbNewLine)
                'sbEmailBody.Append("        <tr>" & vbNewLine)
                'sbEmailBody.Append("            <td style=""PADDING-RIGHT: 15px; PADDING-LEFT: 15px; PADDING-BOTTOM: 15px; PADDING-TOP: 15px"">" & vbNewLine)
                'sbEmailBody.Append("            <p style=""FONT-WEIGHT: bold; COLOR: #003366"">Send To A Friend Details:</p>" & vbNewLine)
                'sbEmailBody.Append("            <p><strong>Senders Name:</strong> {Senders Name}<br /><strong>Senders Email:</strong> {Senders Email}<br /><strong>Recipient Name: </strong>{Recipient Name}<br /><strong>Recipient Email:</strong> {Recipient Email}<br /><strong>Comments:</strong> {Comments}</p>" & vbNewLine)
                'sbEmailBody.Append("            </td>" & vbNewLine)
                'sbEmailBody.Append("        </tr>" & vbNewLine)
                'sbEmailBody.Append("    </tbody>" & vbNewLine)
                'sbEmailBody.Append("</table>" & vbNewLine)

                'sbEmailBody.Replace("{Senders Name}", sender_name)
                'sbEmailBody.Replace("{Senders Email}", sender_email)
                'sbEmailBody.Replace("{Recipient Name}", recipient_name)
                'sbEmailBody.Replace("{Recipient Email}", recipient_email)
                'sbEmailBody.Replace("{Comments}", comments)



                Dim imagePath As String = "http://www.charter.com/visitors/CampaignLanding/Images/"
                Select Case Environment.MachineName.ToLower
                    Case "kstlmcc2p01"
                        '#######
                        'PROD
                        '#######
                        imagePath = "http://www.charter.com/visitors/CampaignLanding/Images/"
                    Case "kstlmcc2p02"
                        '#######
                        'PROD
                        '#######
                        imagePath = "http://www.charter.com/visitors/CampaignLanding/Images/"
                    Case "kstlmweb66"
                        '#######
                        'UAT
                        '#######
                        imagePath = "http://cc2uatw/visitors/CampaignLanding/Images/"
                    Case "kstlmweb67"
                        '#######
                        'UAT
                        '#######
                        imagePath = "http://cc2uatw/visitors/CampaignLanding/Images/"
                    Case "kstlmweb65"
                        '#######
                        'DEV
                        '#######
                        imagePath = "http://kstlmweb65/visitors/CampaignLanding/Images/"
                    Case "kstlintcncegenm"
                        '#######
                        'localhost
                        '#######
                        imagePath = "http://kstlintcncegenm/ui/visitors/CampaignLanding/Images/"
                    Case Else
                        '#####################################
                        'THIS SHOULD ONLY BE LOCALHOST STUFF HERE.
                        '#####################################
                        imagePath = "http://www.charter.com/visitors/CampaignLanding/Images/"
                End Select




                sbEmailBody.Append("    <html>" & vbNewLine)
                sbEmailBody.Append("<head>" & vbNewLine)
                sbEmailBody.Append("</head>" & vbNewLine)
                sbEmailBody.Append("<body>" & vbNewLine)
                sbEmailBody.Append("        <table cellpadding='0' cellspacing='0' width='600' height='800' style='font-family: Arial, Helvetica;font-size: 14px'>" & vbNewLine)
                sbEmailBody.Append("            <tr style='background-color: #cae4f1'>")
                sbEmailBody.Append("                <td colspan='4' height='20'><img src='" & imagePath & "spacer.gif' width='1' height='20'></td>" & vbNewLine)
                sbEmailBody.Append("            </tr>" & vbNewLine)
                sbEmailBody.Append("            <tr style='vertical-align: top'>" & vbNewLine)
                sbEmailBody.Append("                <td width='20' align='top' style='background-color: #cae4f1'><img src='" & imagePath & "spacer.gif' width='20' height='1'></td>" & vbNewLine)
                sbEmailBody.Append("                <td colspan='2' width='560'><img src='" & imagePath & "lt.gif' width='20' height='20' align='left'><img src='" & imagePath & "rt.gif' width='20' height='20' align='right'></td>" & vbNewLine)
                sbEmailBody.Append("                <td width='20' style='background-color: #cae4f1'><img src='" & imagePath & "spacer.gif' width='20' height='1'></td>" & vbNewLine)
                sbEmailBody.Append("            </tr>" & vbNewLine)
                sbEmailBody.Append("            <tr style='vertical-align: top'>" & vbNewLine)
                sbEmailBody.Append("                <td width='20' align='top' style='background-color: #cae4f1'><img src='" & imagePath & "spacer.gif' width='20' height='1'></td>" & vbNewLine)
                sbEmailBody.Append("                <td colspan='2' width='560' style='padding: 20px'>" & vbNewLine)
                sbEmailBody.Append("                    <b>Dear :<u>{Recipient Name}</u></b>" & vbNewLine)
                sbEmailBody.Append("                    <p>" & vbNewLine)
                sbEmailBody.Append("                        <u>{Senders Name}</u> thought that you would like to checkout a special money saving" & vbNewLine)
                sbEmailBody.Append("                        offer from Charter.</p>" & vbNewLine)
                sbEmailBody.Append("                    <p>As part of this special offer, if you sign up today, you can enjoy 'dinner and a movie' on us. To learn more about this opportunity to save money on Charter services by signing up online, <a href='http://www.charter.com/visitors/campaignlandingpage.aspx'> click here</a>.</p>" & vbNewLine)
                sbEmailBody.Append("                    <p>Here's what {Senders Name} had to say about this offer:</p>" & vbNewLine)
                sbEmailBody.Append("                    <p>{Comments}</p>" & vbNewLine)
                sbEmailBody.Append("                </td>" & vbNewLine)
                sbEmailBody.Append("                <td width='20' style='background-color: #cae4f1'><img src='" & imagePath & "spacer.gif' width='20' height='1'></td>" & vbNewLine)
                sbEmailBody.Append("            </tr>" & vbNewLine)
                sbEmailBody.Append("            <tr>" & vbNewLine)
                sbEmailBody.Append("                <td width='20' style='background-color: #cae4f1'><img src='" & imagePath & "spacer.gif' width='20' height='1'></td>" & vbNewLine)
                sbEmailBody.Append("                <td width='280' align='center'><a href='http://www.charter.com/visitors/campaignlandingpage.aspx'><img src='" & imagePath & "click_here.gif' width='234' height='76' border='0'></a></td>" & vbNewLine)
                sbEmailBody.Append("                <td width='280' align='center'><img src='" & imagePath & "charter_logo.gif'></td>" & vbNewLine)
                sbEmailBody.Append("                <td width='20' style='background-color: #cae4f1'><img src='" & imagePath & "spacer.gif' width='20' height='1'></td>" & vbNewLine)
                sbEmailBody.Append("            </tr>" & vbNewLine)
                sbEmailBody.Append("            <tr style='vertical-align: bottom'>" & vbNewLine)
                sbEmailBody.Append("                <td width='20' align='top' style='background-color: #cae4f1'><img src='" & imagePath & "spacer.gif' width='20' height='1'></td>" & vbNewLine)
                sbEmailBody.Append("                <td colspan='2' width='560'><img src='" & imagePath & "lb.gif' width='20' height='20' align='left'><img src='" & imagePath & "rb.gif' width='20'height='20' align='right'></td>" & vbNewLine)
                sbEmailBody.Append("                <td width='20' style='background-color: #cae4f1'><img src='" & imagePath & "spacer.gif' width='20' height='1'></td>" & vbNewLine)
                sbEmailBody.Append("            </tr>" & vbNewLine)
                sbEmailBody.Append("            <tr style='background-color: #cae4f1'>" & vbNewLine)
                sbEmailBody.Append("                <td colspan='4' height='20'><img src='" & imagePath & "spacer.gif' width='1' height='20'></td>" & vbNewLine)
                sbEmailBody.Append("            </tr>" & vbNewLine)
                sbEmailBody.Append("        </table>" & vbNewLine)
                sbEmailBody.Append("    </body>" & vbNewLine)
                sbEmailBody.Append("    </html>" & vbNewLine)

                '###########################
                'ASSIGN VALUES TO THE HTML
                '###########################
                sbEmailBody.Replace("{Senders Name}", sender_name)
                sbEmailBody.Replace("{Senders Email}", sender_email)
                sbEmailBody.Replace("{Recipient Name}", recipient_name)
                sbEmailBody.Replace("{Recipient Email}", recipient_email)
                sbEmailBody.Replace("{Comments}", comments)




                'SEND EMAIL HERE
                Dim iMail As ISupportProvider = CType(Activator.GetObject(GetType(ISupportProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_SupportProvider"))), ISupportProvider)
                iMail.SendEMail("webmaster@chatercom.com", recipient_email, "Charter offers from a friend", sbEmailBody.ToString(), True)
            End If
        Catch ex As Exception
            '##################################################
            'THE CATCH IS LEFT EMPTY TO JUST QUIETLY HANDLE THE 
            'EXCEPTION RATHER THAN FAILING THE PAGE TO THE USER 
            'CALLING THIS.
            '##################################################
        End Try


    End Sub
End Class
