473,473 Members | 4,257 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Sending Mail from asp.net for Gmail ID

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
8 3199
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
"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
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
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

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
Thanks all it worked

have created a small application which sends the mail.

Nov 27 '07 #7
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: ds | last post by:
Hello Iam sending mail from web page like, enquiry form mail using asp and asp.net.while send the mail i don't have any error. but the mail does't reach the destination.can some one give me a...
3
by: HoustonComputerGuy | last post by:
I am working on getting my web applications moved to .Net 2.0 and am having some problems with System.Net.Mail. I get the following error when sending the mail: System.Net.Mail.SmtpException was...
2
by: ינון אזרד | last post by:
Hi. I tring to send a email. I wrote the following lines: (Imports System.Net.Mail) Dim MailMsg As New MailMessage Dim WithEvents MailSmtp As New SmtpClient MailSmtp.Host = gmail.smtp.com...
5
by: Zile | last post by:
I am trying to send mail from web page in asp.net 2.0/VB 2005: Dim Poruka As New System.Web.Mail.MailMessage myMessage.From = "matematic@gmail.com" myMessage.To = "matematic@hotmail.com"...
3
by: dskinibbyb | last post by:
Hi Everybody, I am sending mail using the new class in .Net 2.0. Here while sending internal mails it is giving me problem. Carriage return, Line feed and Spaces are lost while sending mails....
1
by: shubhas | last post by:
hi in my asp.net apllication(c#) am working with sending mail issue.. my following below code is System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage (); ...
2
by: Danny | last post by:
Hi all, Trying to send mail with System.Net.SmtpClient, using very simple code just for testing: SmtpClient smtp = new SmtpClient("mail.server.com", 25); smtp.Credentials = new...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
4
by: Kapil Choubisa | last post by:
Hello all I am using smtp for sending mail. it ask the smtp host name. that is smtp.Host = "smtp.gmail.com"; what is for yahoo/rediff/hotmail is there any one for globle mail systems.
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.