Sending Email Using Third Party SMTP Ex (SMTP - Gmai.coml)
Sending Email Using Third Party SMTP Ex (SMTP - Gmai.coml)
I. ‘using System;
II. ‘using System.Data;
III. ‘using System.Configuration;
IV. ‘using System.Collections;
V. ‘using System.Web;
VI. ‘using System;
VII. ‘using System.Collections.Generic;
VIII. ‘using System.Web;
IX. ‘using System.Web.UI;
X. ‘using System.Web.UI.WebControls;
XI. ‘using System.Net.Mail;
XII. ‘using System.Net;
XVII. ‘}
XVIII. ‘protected void SendMail(object sender, EventArgs e)
XIX. ‘{
a. ‘MailMessage mail = new MailMessage();
b. ‘mail.From = new MailAddress(EmailTB.Text);
c. ‘mail.To.Add("[email protected]");
d. ‘mail.Subject = "Contact Us";
e. ‘mail.IsBodyHtml = true;
f. ‘mail.Body = "First Name: " + FNameTB.Text + "<br />";
g. ‘mail.Body += "Last Name: " + LNameTB.Text + "<br />";
h. ‘mail.Body += "Email: " + EmailTB.Text + "<br />";
i. ‘mail.Body += "Comments: " + CommentsTB.Text + "<br />";
‘}
‘}
I. ‘<?xml version="1.0"?>
II. ‘<!--
III. ‘Note: As an alternative to hand editing this file you can use
‘the
IV. ‘web admin tool to configure settings for your application. Use
V. ‘the Website->Asp.Net Configuration option in Visual Studio.
VI. ‘A full list of settings and comments can be found in
VII. ‘machine.config.comments usually located in
VIII. ‘\Windows\Microsoft.Net\Framework\v2.x\Config
IX. ‘-->
X. ‘<configuration>
XI. ‘<system.net>
XII. ‘<mailSettings>
XIII. ‘<smtp deliveryMethod="Network" from="SomeWebsite Admin
‘<[email protected]>">
XIV. ‘<network host="smtp.gmail.com" port="587"
‘defaultCredentials="true" userName="[email protected]"
‘password="password" />
XV. ‘</smtp>
XVI. ‘</mailSettings>
XVII. ‘</system.net>
XVIII. ‘<system.web>
XIX. ‘<customErrors mode="Off"/>
XX. ‘</system.web>
XXI. </configuration>
Alternatively you can pass the relative IP address of your SMTP relay host.