DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 620 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

39
kicks
published 1 year, 4 months ago, submitted by yousefla 1 year, 4 months ago

mycsharpcorner.com — Did you know you can use Google's gmail mail server to send and receive emails programmatically? It's true, Google folks allow you to use their mail servers to send emails programmatically from your applications.

Add a comment 5 comments | category: | Views: 51 | Get KickIt image code
tags: , , , , | tag it

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:

Comments:
This works with any SMTP server that permits authentication. It's certainly not limited to Google.
posted by senfo 1 year, 4 months ago
Protip: don't forget your try/catch block. Also, asynchronous method calls are a good idea for network calls. Don't block your UI thread with this call!
posted by yesthatmcgurk yesthatmcgurk 1 year, 4 months ago
Yesthat... Agreeable, whenever going to production, a good program must catch all errors; I just wanted to make the article small and simple. I also agree 100% about the asynchronous call to avoid performance bottlenecks, but then again, we're talking GOOOGLE servers here ;-)
posted by yousefla 1 year, 4 months ago
hi..when i tried to execute this code, it throws an exception,
can u tell me why?

code:
public string sendMail(string to, string from, string subject, string body)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress(from);
mail.To.Add(to);
mail.Subject = subject;
mail.Body = body;

SmtpClient cl = new SmtpClient("smtp.gmail.com",587);
cl.EnableSsl = true;
cl.Credentials = new NetworkCredential("ashin007@gmail.com", pass);
cl.Send(mail);
}

exception:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at Service.sendMail(String to, String from, String subject, String body)
posted by ashin 1 year, 1 month ago
hi,

i was tring to send email using ASP with "CDO.Message" by connecting to google mail server .

With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mail.google.com"
.Update
End With

and got the following error message:

CDO.Message.1 error '80040213'
The transport failed to connect to the server.

any ideas ?

thanks
posted by eric 10 months, 18 days ago



information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads via The Lounge