Ok, Google (Gmail) is hosting our emails through "domain sharing". Basically, any emails being sent to raylinder@glacsy.com goes to Gmail and Gmail hosts it. My concern was SMTP from our website in ASP.NET 2.0. Yes, sound overwhelmingly exciting doesn't it? Well, there's is a way, the LONG and easier way or the short and painful way. LONG and easier way is, you build a SMTP class/control and namespace it to something like Glacsy.Net.WebMail then create a the SMTP assembly to accept parameters like From, To, BCC, Subject, Body. Then every page you want to send email, just map it to the class. Long time to build it, easy to use. I'm not getting into the short and painful way, you can just use your imagination. Below is some code on your page (yes, finally I'm including code):
Glacsy.Net.WebMail.SMTP("welcome@glacsy.com", someone@their-email.com, "bcc@some-one-else.com", "My Subject", "My body or message...");
This is what you would use to pass a page to email. Below is the SMTP.cs code in the App_Code directory to use:
using System.Net;
using System.Net.Mail;
using System.Text;
namespace Glacsy.Net
{
public class WebMail
{
public static void SMTP(string from, string to, string bcc, string subject, string body)
{
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress(from);
mailMsg.To.Add(to);
mailMsg.Subject = subject;
mailMsg.IsBodyHtml = true;
mailMsg.BodyEncoding = Encoding.UTF8;
mailMsg.Body = body;
mailMsg.Priority = MailPriority.Normal;
// Smtp configuration
SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("youremail@gmail.com", "yourpassword");
client.Port = 587; //or use 465
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
object userState = mailMsg;
try
{
//you can also call client.Send(msg)
client.SendAsync(mailMsg, userState);
}
catch (SmtpException)
{
//Catch errors...
}
}
}
}
Now, this is the easiest and simplest way I could think for sending email via Gmail. If you have a better way, let me know and I'll test it out. The good thing is the speed of development this setup will provide in the long run. I may build and release a .dll file of this in the future for everyone. But for now, enjoy...
posted on Saturday, January 13, 2007 12:41 AM
Feedback
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/18/2007 12:40 PM |
thxx
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/26/2007 5:25 AM |
Hi dear, its good and interests informations for me. Thanks.
# re: Using SMTP and Gmail in ASP.NET 2.0...
12/9/2007 2:00 PM |
We offer the largest collection of polyphonic ringtones, monophonic ringtones, mobile videos, color wallpapers, color screensavers, real sounds.
# re: Using SMTP and Gmail in ASP.NET 2.0...
12/9/2007 2:00 PM |
We offer the largest collection of polyphonic ringtones, monophonic ringtones, mobile videos, color wallpapers, color screensavers, real sounds.
# re: Using SMTP and Gmail in ASP.NET 2.0...
12/26/2007 12:37 PM |
If you are looking for the replica watch and information about it, you came to the right place.
# re: Using SMTP and Gmail in ASP.NET 2.0...
2/13/2008 1:45 PM |
TSKLER
# re: Using SMTP and Gmail in ASP.NET 2.0...
7/16/2008 11:02 AM |
thank you dostum...
# re: Using SMTP and Gmail in ASP.NET 2.0...
7/25/2008 1:04 PM |
very very nice
# re: Using SMTP and Gmail in ASP.NET 2.0...
7/27/2008 12:31 PM |
thnak you.
# re: Using SMTP and Gmail in ASP.NET 2.0...
9/14/2008 4:14 AM |
Thanks so much.
# re: Using SMTP and Gmail in ASP.NET 2.0...
10/26/2008 3:05 AM |
Thanks so much çocuk oyunlari
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:46 PM |
oyun indir
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:48 PM |
çet
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:49 PM |
cet
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:49 PM |
chat
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:49 PM |
sohpet
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:51 PM |
chat siteleri
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:52 PM |
sohbet siteleri
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:53 PM |
çet siteleri
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:54 PM |
radyo
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:55 PM |
vps
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:56 PM |
asksevgi
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/22/2008 3:57 PM |
sevgi
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/24/2008 6:05 PM |
Thank You
# re: Using SMTP and Gmail in ASP.NET 2.0...
12/3/2008 3:09 PM |
just test