Beruflich Dokumente
Kultur Dokumente
http://www.codeproject.com/Tips/520998/Send-Email-from-Yahoo-Gm...
Not quite what you are looking for? You may want to try: Send 1000s of Emails Without Timeout Sending Email Using Embedded Images
9,890,640 members (46,312 online) manuu 2K
highlights off
Sign out
home
articles
quick answers
discussions
features
community
help
send email in c#
Next
About Article
A Class for Sending Email Easily from Yahoo, Gmail, Hotmail or your own email. Type Licence Tip/Trick CPOL 3 Jan 2013 8,453 860 21 times
Download EmailSender.zip
Comments & Discussions (3)
Introduction
A Class for Sending Email Easily from Yahoo, Gmail, Hotmail or your own email.
C# Beginner
EmailSender es = new EmailSender(); es.From = "myemail@yahoo.com"; es.To = "anyaddress@anydomain.com"; es.Password = "mypwd"; es.Subject = "Test Mail"; es.Body = "hello"; es.IsHtmlBody = false; es.EmailProvider = EmailSender.EmailProviderType.Yahoo; es.Send();
es.EmailProvider = EmailSender.EmailProviderType.Gmail;
es.EmailProvider = EmailSender.EmailProviderType.Hotmail;
Sending Email from your own domain. Change the EmailProvider to Other
Collapse | Copy Code
es.AttachFile = "C:\\MyFile.zip";
es.AttachmentFileList.Add("C:\\MyFile1.zip"); es.AttachmentFileList.Add("C:\\MyFile2.zip");
Top News
Collapse | Copy Code
Related Videos
1 of 3
25/05/2013 01:24
http://www.codeproject.com/Tips/520998/Send-Email-from-Yahoo-Gm...
And Email
using (var client = new SmtpClient("smtp.mail.yahoo.com", 587)) { client.Credentials = new NetworkCredential("myemail@yahoo.com", "mypwd"); var mail = new MailMessage(); mail.From = new MailAddress("myemail@yahoo.com"); mail.To.Add("anyaddress@anydomain.com"); mail.Subject = "Test mail"; mail.Body = "test body"; client.Send(mail); }
Note: In earlier version of .NET Framework, SmtpClient has not implement IDisposable. Therefore, you can't use Using to declare it. Sending email from Gmail:
Collapse | Copy Code
Related Articles
A POP3 Client in C# .NET Sending Email using MAPI - A COM DLL Using Gmail Account to Send Emails With Attachment BooProd.BMail - Sending dynamically generated emails C# Code snippet to send an Email with attachment from Outlook, Yahoo, HotMail, AOL and Gmail Mail Monitor++
using (var client = new SmtpClient("smtp.gmail.com", 587)) { client.Credentials = new NetworkCredential("myemail@gmail.com", "mypwd"); var mail = new MailMessage(); ... ... client.EnableSsl = true; client.Send(mail); }
MySendToMail: A Replacement for Windows SendTo/Email Send Calendar Appointment As Email Attachment System.Web.Mail and the pickup directory Sending Emails using .NET Part II Send 1000s of Emails Without Timeout How to send an SMS message from an application A class for sending emails with attachments in C#.
using (var client = new SmtpClient("smtp.live.com", 587)) { client.Credentials = new NetworkCredential("myemail@live.com", "mypwd"); var mail = new MailMessage(); ... ... client.EnableSsl = true; client.Send(mail); }
Alternatively, you may refer OriginalGriff's examples: Sending an Email in C# with or without attachments: generic routine.
License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
What not to do: Anti-Patterns and the Solutions IP Announce by Email A versatile HTML form mail script for classic ASP
Sending Email Using Embedded Images Sending Email through ASP. NET VB.NET 2005 SMTP Email Message Windows Email Client application using .NET (C#)
Article Top
Like
Tweet
13
Rate this:
Poor
Excellent
Vote
Noise Medium
Per page 25
Update
Nice work
with a little tweak it works fine for me thanks, nice work Mustafa Hamed
Reply Email View Thread Permalink Bookmark
MustafaHamed
Exception
mughal_1583
2 of 3
25/05/2013 01:24
http://www.codeproject.com/Tips/520998/Send-Email-from-Yahoo-Gm...
I am getting exception while running this code, i m using window 7 with vs 2010. Kindly guide me in this regard System.Net.Mail.SmtpException was unhandled Message=Failure sending mail. Source=System StackTrace: at System.Net.Mail.SmtpClient.Send(MailMessage message) at EmailSender.SendMail(MailMessage mail) in C:\Users\Mughal\documents\visual studio 2010\Projects\TestingEmail\TestingEmail\EmailSender.cs:line 158 at EmailSender.Send() in C:\Users\Mughal\documents\visual studio 2010\Projects\TestingEmail\TestingEmail\EmailSender.cs:line 100 at TestingEmail.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\Mughal\documents\visual studio 2010\Projects\TestingEmail\TestingEmail \Form1.cs:line 34 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at TestingEmail.Program.Main() in C:\Users\Mughal\Documents\Visual Studio 2010\Projects\TestingEmail\TestingEmail\Program.cs:line 18 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.IO.IOException Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. Source=System StackTrace: at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.DelegatedStream.Read(Byte[] buffer, Int32 offset, Int32 count) at System.Net.BufferedReadStream.Read(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String& response) at System.Net.Mail.StartTlsCommand.Send(SmtpConnection conn) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) InnerException: System.Net.Sockets.SocketException Message=An existing connection was forcibly closed by the remote host Source=System ErrorCode=10054 NativeErrorCode=10054 StackTrace: at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) InnerException:
Reply Email View Thread Permalink Bookmark
My vote of 5
Nice work, keep it simple
Reply Email View Thread Permalink Bookmark
Edo Tzumer
Refresh
General
News
Suggestion
Question
Bug
Answer
Joke
Rant
Admin
Article Copyright 2013 by adriancs Everything else Copyright CodeProject, 1999-2013 Terms of Use
Permalink | Advertise | Privacy | Mobile Web03 | 2.6.130523.1 | Last Updated 3 Jan 2013
3 of 3
25/05/2013 01:24