Selasa, 27 November 2012

Make TextBoox content Email sent With DotnetNuke (SMTP SERVER)

  I Have One Textboox and One Button to submit Content Email From TextBoox and Email Will sent with SMTP Server Using DotnetNuke.
This ScreenShoot Proses

has sent by user with click button submit then user will have email confirmation .
Thisbelow screenshot

oke.This code with c# in.ascx and .ascx.cs



this code into .ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Default.ascx.cs" Inherits="Module.Subscribe.I.Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<telerik:RadWindow ID="rdwReport" runat="server" Height="250px" Width="450px" VisibleOnPageLoad="false"
    Modal="true" BackColor="#DADADA" VisibleStatusbar="false" Behaviors="Close" Title="Report Data Tersimpan">
    <contenttemplate>
   
    <style type="text/css" >
        .label
        {
            padding-left: 63px;
            font-size: 30px;
        }
        .button
        {
            padding-left: 68px;
            padding-right: 59px;
        }
        .bacghroud
        {
            overflow: auto;
            border: 0px;
            height: 211px;
            width: 423px;
            background-color: blanchedAlmond;
        }
    </style>
     

        <script type="text/javascript">
            function OnClientClick() {
                var win = $find('<%=rdwReport.ClientID %>');
                win.Close();
            }
          
        </script>
       

        <table class ="bacghroud">
            <tr>
                <td class ="label">
                  <center><asp:Label ID="lblMessage1" runat="server" Text="Data Telah Tersimpan" /></center> 
                </td>
            </tr>
            <tr>
                <td class ="button">
             <center ><asp:Button ID="btnClose" runat="server" Text="Close" OnClientClick ="OnClientClick(this);return false;" /></center>     
                </td>
            </tr>
           
        </table>
    </contenttemplate>
</telerik:RadWindow>
<asp:MultiView ID="multiviewLatter" runat="server">
    <asp:View ID="viewlater" runat="server">
        <table>
            <tr>
                <td>
                    <asp:TextBox ID="txtEmail1" runat="server" Width="400px" Height="50px" BorderColor="ActiveCaption"
                        ValidationGroup="Subcribe1"></asp:TextBox>
                    <br />
                    <asp:RequiredFieldValidator ID="rv1" runat="server" ErrorMessage="Mohon Email di isi"
                        ForeColor="Red" Font-Size="12px" ControlToValidate="txtEmail1" ValidationGroup="Subcribe1"
                        SetFocusOnError="true"></asp:RequiredFieldValidator>
                   <br />
                    <asp:RegularExpressionValidator ID="Rgv1" runat="server" ControlToValidate="txtEmail1"
                        ErrorMessage="Email Yang anda Masukan Salah" Style="z-index: 101; left: 424px; position: absolute;
                        top: 285px" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="Subcribe1">
                    </asp:RegularExpressionValidator>
                </td>
                <td>
                    <asp:Button ID="btnsend1" runat="server" Text="Submit" Height="54px" Width="145px"
                        OnClick="btnsubmit_click1" ValidationGroup="Subcribe1" CausesValidation="true" />
                       
                </td>
                <td>
                    <asp:HyperLink ID="linknewslatter" runat="server" Text="NewsLatter for Subscribe"
                        NavigateUrl="http://www.yahoo.com"></asp:HyperLink>
                </td>
            </tr>
        </table>
    </asp:View>
</asp:MultiView>



This code into .ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Entities.Modules;
using Telerik.Web.UI;
using System.Net;
using System.Net.Mail;

namespace Module.Subscribe.I
{
    public partial class Default : PortalModuleBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            multiviewLatter.SetActiveView(viewlater);


        }



        protected void btnsubmit_click1(object sender, EventArgs e)
        {
            try
            {



                Module.Fuel.Subscribe.I.Entitas.NewsLetter objnewslatter1 = new Module.Fuel.Subscribe.I.Entitas.NewsLetter();
                objnewslatter1.Email = txtEmail1.Text.Trim();
                Module.Fuel.Subscribe.I.Controler.SubscribeI ctlr = new Module.Fuel.Subscribe.I.Controler.SubscribeI();
                ctlr.addNewsLatter(objnewslatter1);

              
                try
                {

                    DotNetNuke.Services.Mail.Mail.SendEmail("andriamayanto@gmail.com", "andriamayanto@gmail.com", txtEmail1.Text.Trim(), "Bataviasoft Test Email", "Terimakasih Anda telah Ikut Berpartisipasi Dalam Wrbsite ini <br>http://news.detik.com/read/2012/11/27/041040/2102111/10/?992204topnews</br>");

                }
                catch (Exception ex)
                {
                }



                rdwReport.VisibleOnPageLoad = true;
                txtEmail1.Text = "";

            }

            catch (Exception ex)
            {
            }
        }
    }

}
       
   
                                                                            ----Thank You ----



Tidak ada komentar:

Posting Komentar