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
# re: Using SMTP and Gmail in ASP.NET 2.0...
12/27/2008 7:41 PM |
CET
1/9/2009 5:58 PM |
thank you
# re: Using SMTP and Gmail in ASP.NET 2.0...
2/3/2009 7:52 PM |
thanks
# re: Using SMTP and Gmail in ASP.NET 2.0...
2/3/2009 7:55 PM |
thanks
# re: Using SMTP and Gmail in ASP.NET 2.0...
2/3/2009 7:55 PM |
thanks
# re: Using SMTP and Gmail in ASP.NET 2.0...
2/3/2009 7:56 PM |
thanks
# re: Using SMTP and Gmail in ASP.NET 2.0...
2/21/2009 1:44 AM |
Thank's Very Good..
# re: Using SMTP and Gmail in ASP.NET 2.0...
3/17/2009 1:44 PM |
thanks
# re: Using SMTP and Gmail in ASP.NET 2.0...
3/17/2009 3:04 PM |
great
# re: Using SMTP and Gmail in ASP.NET 2.0...
3/17/2009 3:05 PM |
good article
# re: Using SMTP and Gmail in ASP.NET 2.0...
3/21/2009 1:12 PM |
Very Good! Thanks..
# re: Using SMTP and Gmail in ASP.NET 2.0...
3/25/2009 9:49 AM |
thank you.
# re: Using SMTP and Gmail in ASP.NET 2.0...
4/2/2009 10:28 AM |
sas asas a
# re: Using SMTP and Gmail in ASP.NET 2.0...
4/2/2009 11:04 AM |
as saqw a sazx
# re: Using SMTP and Gmail in ASP.NET 2.0...
4/2/2009 11:05 AM |
asas qw wzxcc er
# re: Using SMTP and Gmail in ASP.NET 2.0...
4/2/2009 11:06 AM |
as qwwq 12 asa saa qw wqw1212ewr445
# re: Using SMTP and Gmail in ASP.NET 2.0...
4/5/2009 9:40 PM |
Thanks for sharing and information. To explore the beautiful
# re: Using SMTP and Gmail in ASP.NET 2.0...
4/5/2009 9:40 PM |
thank
# re: Using SMTP and Gmail in ASP.NET 2.0...
4/5/2009 9:41 PM |
thanks
6/5/2009 11:18 AM |
casus telefon, telefon dinleme, ortam dinleme, dinleme cihazi
6/5/2009 11:18 AM |
casus telefon, telefon dinleme, ortam dinleme, dinleme cihazi
6/5/2009 11:19 AM |
mirc, mirc, mirç, mirç, mirc indir, irc komutlari, chat, muhabbet, script indir, mirc download, mIRC
# re: Using SMTP and Gmail in ASP.NET 2.0...
7/21/2009 11:31 AM |
Penis enlarger pills prosolution penis enlarger, penis size was prepared to increase the natural content is a special formula. Improve your health and your sexual erection problems resolved many of the world prosolution penis enlarger formula includes a special blend of herbs. So far, only America and Europe in the complaint or any adverse effects from this product is seen. This is an incredible warranty. Your sex life with these products now sattilan in Turkey will be perfect. You'll see from the penis enlarger pills Prosolution Other Impacts.
# re: Using SMTP and Gmail in ASP.NET 2.0...
7/21/2009 11:32 AM |
Penis enlarger pills prosolution penis enlarger, penis size was prepared to increase the natural content is a special formula. Improve your health and your sexual erection problems resolved many of the world prosolution penis enlarger formula includes a special blend of herbs. So far, only America and Europe in the complaint or any adverse effects from this product is seen. This is an incredible warranty. Your sex life with these products now sattilan in Turkey will be perfect. You'll see from the penis enlarger pills Prosolution Other Impacts.
# re: Using SMTP and Gmail in ASP.NET 2.0...
8/8/2009 9:19 AM |
Penis enlarger pills prosolution penis enlarger, penis size was prepared to increase the natural content is a special formula. Improve your health and your sexual erection problems resolved many of the world prosolution penis enlarger formula includes a special blend of herbs. So far, only America and Europe in the complaint or any adverse effects from this product is seen. This is an incredible warranty. Your sex life with these products now sattilan in Turkey will be perfect. You'll see from the penis enlarger pills Prosolution Other Impacts.
# re: Using SMTP and Gmail in ASP.NET 2.0...
9/4/2009 2:52 PM |
You often write very interesting articles.
# re: Using SMTP and Gmail in ASP.NET 2.0...
9/10/2009 2:06 AM |
thanks admin for article
# re: Using SMTP and Gmail in ASP.NET 2.0...
9/10/2009 2:07 AM |
thanks admin
your article is very good
# re: Using SMTP and Gmail in ASP.NET 2.0...
9/27/2009 12:42 AM |
humis
# re: Using SMTP and Gmail in ASP.NET 2.0...
10/10/2009 11:45 PM |
thank you
# re: Using SMTP and Gmail in ASP.NET 2.0...
10/10/2009 11:46 PM |
thanks for share
# re: Using SMTP and Gmail in ASP.NET 2.0...
10/26/2009 4:08 AM |
buradan doom gecti kardes ekleyip gectim
# re: Using SMTP and Gmail in ASP.NET 2.0...
10/27/2009 10:44 AM |
thanks for share
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/3/2009 1:05 AM |
ekleyin llan:=))
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/8/2009 8:18 AM |
I like very much the writings and pictures and explanations in your adress so I look forward to see your next writings.
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/12/2009 11:55 PM |
wow…great collection! Thanks for sharing here.
11/14/2009 5:50 AM |
Thanks Admin wery good :)
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/15/2009 4:46 AM |
How are you
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/15/2009 7:26 PM |
How are you
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/15/2009 8:48 PM |
hii are you
# re: Using SMTP and Gmail in ASP.NET 2.0...
11/25/2009 12:56 PM |
This code uses gmail smtp to send emails. It uses authentication. Replace username with your gmail username and password with gmail password.
# re: Using SMTP and Gmail in ASP.NET 2.0...
12/9/2009 6:18 PM |
sinemalar
# re: Using SMTP and Gmail in ASP.NET 2.0...
12/21/2009 2:52 PM |
thanks
# re: Using SMTP and Gmail in ASP.NET 2.0...
12/21/2009 2:56 PM |
thanks
# re: Using SMTP and Gmail in ASP.NET 2.0...
12/21/2009 11:46 PM |
hi how are you all
# re: Using SMTP and Gmail in ASP.NET 2.0...
1/6/2010 4:58 AM |
acai acai
# re: Using SMTP and Gmail in ASP.NET 2.0...
1/10/2010 10:39 PM |
thanks
# re: Using SMTP and Gmail in ASP.NET 2.0...
1/10/2010 10:39 PM |
thanks you
# re: Using SMTP and Gmail in ASP.NET 2.0...
1/10/2010 10:40 PM |
thanks you
# re: Using SMTP and Gmail in ASP.NET 2.0...
1/10/2010 10:41 PM |
thankls
# re: Using SMTP and Gmail in ASP.NET 2.0...
1/11/2010 4:21 PM |
thank
# re: Using SMTP and Gmail in ASP.NET 2.0...
1/11/2010 4:21 PM |
thank you
# re: Using SMTP and Gmail in ASP.NET 2.0...
1/11/2010 4:21 PM |
thanks you
# Sesli Chat Sesli Sohbet Webcam SesliChat SesliSohbet
1/16/2010 8:42 AM |
Thank you editors for the topic.Its include a lot of useful informations.i join this blog i couldnt see unnecessary arguments and it makes us happy thnx all moderator n editors.
# Sesli Chat Sesli Sohbet Webcam SesliChat SesliSohbet
1/16/2010 8:42 AM |
Thank you editors for the topic.Its include a lot of useful informations.i join this blog i couldnt see unnecessary arguments and it makes us happy thnx all moderator n editors.
# Sesli Chat Sesli Sohbet Webcam SesliChat SesliSohbet
1/16/2010 8:42 AM |
Thank you editors for the topic.Its include a lot of useful informations.i join this blog i couldnt see unnecessary arguments and it makes us happy thnx all moderator n editors.
# Sesli Chat Sesli Sohbet Webcam SesliChat SesliSohbet
1/16/2010 8:42 AM |
Thank you editors for the topic.Its include a lot of useful informations.i join this blog i couldnt see unnecessary arguments and it makes us happy thnx all moderator n editors.
# re: Using SMTP and Gmail in ASP.NET 2.0...
1/17/2010 2:14 AM |
OKEYBIZ
# re: Using SMTP and Gmail in ASP.NET 2.0...
1/20/2010 3:47 AM |
Thanks you..
# re: Using SMTP and Gmail in ASP.NET 2.0...
2/3/2010 6:34 PM |
good page
# re: Using SMTP and Gmail in ASP.NET 2.0...
2/14/2010 4:16 AM |
thanks you
# re: Using SMTP and Gmail in ASP.NET 2.0...
2/14/2010 4:16 AM |
thanks you
2/24/2010 1:28 PM |
Thank you for great article.
# re: Using SMTP and Gmail in ASP.NET 2.0...
3/13/2010 5:15 AM |
Good job.
# re: Using SMTP and Gmail in ASP.NET 2.0...
3/13/2010 5:16 AM |
Fantastic.