By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,309 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,309 IT Pros & Developers. It's quick & easy.

Sending Mail from asp.net for Gmail ID

P: n/a
Hi,
Im trying to send mail from asp.net page to gmail account.
Im trying to do this with the help of below code, but cant archive
it.

MailMessage message = new MailMessage("xx*@gmal.com", "xx*@gmal.com",
"xx*@gmal.com", "xx*@gmal.com");
SmtpClient smtp = new SmtpClient("smtp.gmail.com",465);
smtp.Send(message);

The above code doesn't seem to work..

Please help
Nov 24 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Jack,

Ports 465/995 are secure in Gmail. There is a free SSL library which Gmail use for their
Gmail e-mail tool. See below:

http://www.mentalis.org/soft/projects/ssocket/

--
Newbie Coder
(It's just a name)
"jack" <ga**********@gmail.comwrote in message
news:5d**********************************@d27g2000 prf.googlegroups.com...
Hi,
Im trying to send mail from asp.net page to gmail account.
Im trying to do this with the help of below code, but cant archive
it.

MailMessage message = new MailMessage("xx*@gmal.com", "xx*@gmal.com",
"xx*@gmal.com", "xx*@gmal.com");
SmtpClient smtp = new SmtpClient("smtp.gmail.com",465);
smtp.Send(message);

The above code doesn't seem to work..

Please help
Nov 24 '07 #2

P: n/a
"jack" <ga**********@gmail.comwrote in message
news:5d**********************************@d27g2000 prf.googlegroups.com...
Im trying to send mail from asp.net page to gmail account.
Im trying to do this with the help of below code, but cant archive
it.
MailMessage message = new MailMessage("xx*@gmal.com", "xx*@gmal.com",
"xx*@gmal.com", "xx*@gmal.com");
SmtpClient smtp = new SmtpClient("smtp.gmail.com",465);
smtp.Send(message);

The above code doesn't seem to work..
There are several things here:

1) You don't need to use GMail as the relay server just because you want to
send email *to* a Gmail account...

2) What you mean by "can't archive it"? What archive are you talking
about...?

3) The MailMessage() object declaration is incorrect:
http://www.systemnetmail.com/faq/3.1.1.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 24 '07 #3

P: n/a
Here is sample working Gmail Sender code. Watch carefully at everything that
is done:

using System;
using System.Collections.Generic;
using System.Text;

namespace PAB.Utils
{
public static class Sender
{
public static void SendGmail(string userName, string password,
string mailFrom,
string mailTo,string subject, string
message,bool isBodyHtml)
{
System.Net.Mail.MailMessage msg = new
System.Net.Mail.MailMessage(mailFrom,mailTo,
subject, message);
msg.IsBodyHtml = isBodyHtml;
System.Net.NetworkCredential cred = new
System.Net.NetworkCredential(userName, password);
System.Net.Mail.SmtpClient mailClient = new
System.Net.Mail.SmtpClient("smtp.gmail.com",587);
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = cred;
mailClient.Send(msg);
}
}
}
--
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"jack" wrote:
Hi,
Im trying to send mail from asp.net page to gmail account.
Im trying to do this with the help of below code, but cant archive
it.

MailMessage message = new MailMessage("xx*@gmal.com", "xx*@gmal.com",
"xx*@gmal.com", "xx*@gmal.com");
SmtpClient smtp = new SmtpClient("smtp.gmail.com",465);
smtp.Send(message);

The above code doesn't seem to work..

Please help
Nov 24 '07 #4

P: n/a
You should not send your message to gmail directly.

Instead, use the SMTP server that belongs to your domain/internet provider.

"jack" <ga**********@gmail.comwrote in message
news:5d**********************************@d27g2000 prf.googlegroups.com...
Hi,
Im trying to send mail from asp.net page to gmail account.
Im trying to do this with the help of below code, but cant archive
it.

MailMessage message = new MailMessage("xx*@gmal.com", "xx*@gmal.com",
"xx*@gmal.com", "xx*@gmal.com");
SmtpClient smtp = new SmtpClient("smtp.gmail.com",465);
smtp.Send(message);

The above code doesn't seem to work..

Please help

Nov 25 '07 #5

P: n/a

I have a gmail example wired up (downloadable code) at:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry


"jack" <ga**********@gmail.comwrote in message
news:5d**********************************@d27g2000 prf.googlegroups.com...
Hi,
Im trying to send mail from asp.net page to gmail account.
Im trying to do this with the help of below code, but cant archive
it.

MailMessage message = new MailMessage("xx*@gmal.com", "xx*@gmal.com",
"xx*@gmal.com", "xx*@gmal.com");
SmtpClient smtp = new SmtpClient("smtp.gmail.com",465);
smtp.Send(message);

The above code doesn't seem to work..

Please help

Nov 25 '07 #6

P: n/a
Thanks all it worked

have created a small application which sends the mail.

Nov 27 '07 #7

P: n/a
i want to send a msge to 24*****@gmail.com

"jack" wrote:
Thanks all it worked

have created a small application which sends the mail.

Feb 8 '08 #8

P: n/a
I want a lot of thing but I do not post them all here :)

If you have a question then ask and do not forget to provide specific
problem you face with descriptive error you get (if any)

George.
"shobaguna" <sh*******@discussions.microsoft.comwrote in message
news:C6**********************************@microsof t.com...
>i want to send a msge to 24*****@gmail.com

"jack" wrote:
>Thanks all it worked

have created a small application which sends the mail.


Feb 8 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.