<body bgcolor="#ccccff"> <form id="form1" runat="server"> <div> <table width="962" bgcolor="#ccccff"> <tr> <td class="style5"> <asp:Button ID="btnSend" Text="Send" runat="server" Font-Size="Small" onclick="btnSend_Click2"/></td> <td class="style6"> <asp:Button ID="btnSave" Text="Save" runat="server" Font-Size="Small" onclick="btnSave_Click"/></td> <td> <asp:Label ID="Lbldisplay" runat="server" Text="Label"></asp:Label> </td> </tr> </table> <hr /> </div> <table class="style1" width="962" align="center"> <tr> <td class="style4"> <asp:Label ID="lblFrm" runat="server" Text="From :-" Font-Size="Small"></asp:Label> </td> <td> <asp:TextBox ID="TxtFrm" runat="server" Height="22px" Width="263px" Enabled="False"></asp:TextBox> </td> </tr> <tr> <td class="style4"> <asp:Label ID="lblto" runat="server" Text="To :-" Font-Size="Small"></asp:Label> </td> <td> <asp:TextBox ID="Txtto" runat="server" Height="22px" Width="263px"></asp:TextBox> </td> </tr> <tr> <td class="style4"> <asp:Label ID="Lblcc" runat="server" Text="Cc :-" Font-Size="Small"></asp:Label> </td> <td> <asp:TextBox ID="Txtcc" runat="server" Height="22px" Width="263px"></asp:TextBox> </td> </tr> <tr><td> <asp:Label ID="Lblcc0" runat="server" Text="Bcc :-" Font-Size="Small"></asp:Label> </td> <td> <asp:TextBox ID="txtbcc" runat="server" Height="22px" Width="263px"></asp:TextBox> </td></tr> <tr><td class="style4"> <asp:Label ID="lblattach0" Text="Subject :-" runat="server" Font-Size="Small"></asp:Label> </td> <td> <asp:TextBox ID="Txtsub" runat="server" Height="22px" Width="263px"></asp:TextBox> attachment:<asp:FileUpload ID="attachmenttext" runat="server" /> </td> </tr> </table> <hr /> <table class="style1"> <tr> <td> <asp:TextBox ID="Txtbody" runat="server" Height="267px" Width="896px"></asp:TextBox> </td> </tr> </table> <p> <asp:Label ID="Lblsuccessfully" runat="server" Text="Label" Font-Size="Small"></asp:Label> </p> </form> </body>
protected void btnSend_Click2(object sender, EventArgs e) { try { MailMessage ms = new MailMessage("test@gmail.com",Txtto.Text,Txtsub.Text,Txtbody.Text); ms.IsBodyHtml = false; NetworkCredential nc = new NetworkCredential("test@prayoglabs.com", "prayoglabs@123"); SmtpClient obj = new SmtpClient("mail.gmail.com", portnumber); if(txtbcc.Text!="") ms.Bcc.Add(txtbcc.Text); if(Txtcc.Text!="") ms.CC.Add(Txtcc.Text); if (attachmenttext.HasFile) { string atach = Path.GetFileName(attachmenttext.PostedFile.FileName); Attachment myattach = new Attachment(attachmenttext.FileContent, atach); ms.Attachments.Add(myattach); } obj.UseDefaultCredentials = false; obj.Credentials = nc; obj.Send(ms); Lblsuccessfully.Text = "Mail Send Successfully"; Txtto.Text = " "; Txtcc.Text = " "; Txtsub.Text = " "; Txtbody.Text = " "; txtbcc.Text = " "; } catch (Exception ex) { Lblsuccessfully.Text = ex.Message; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)