Welcome to Dream.In.Code
Become a C# Expert!

Join 150,416 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,016 people online right now. Registration is fast and FREE... Join Now!




send email with SMTP

 
Reply to this topicStart new topic

send email with SMTP

kingmighty_spades
14 Mar, 2008 - 01:13 PM
Post #1

New D.I.C Head
*

Joined: 8 Feb, 2008
Posts: 20


My Contributions
Hi

Ive written an SMPT server that works great but when I want to use my own messenger(site) adres instead of ( smtp.gmail or outlook wich both worked fine ) even though Ive created the user and pass in my messenger it wont work ohno.gif

Any and all help appreciated ,Ill be waiting for reply smile.gif
User is offlineProfile CardPM
+Quote Post

RodgerB
RE: Send Email With SMTP
15 Mar, 2008 - 06:25 AM
Post #2

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,166



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
Please post the code that works, and the code that doesn't work and we will be able to help solve your problem. Please ensure you post your code like this: code.gif. Thanks smile.gif.
User is online!Profile CardPM
+Quote Post

kingmighty_spades
RE: Send Email With SMTP
15 Mar, 2008 - 07:54 AM
Post #3

New D.I.C Head
*

Joined: 8 Feb, 2008
Posts: 20


My Contributions
the code that works

CODE


using System.Net.Mail;

            SmtpClient SmtpServer = new SmtpClient();
            SmtpServer.Credentials = new System.Net.NetworkCredential("User gmail", "Paaword");
            SmtpServer.Port = 587;
            SmtpServer.Host = "smtp.gmail.com";
            SmtpServer.EnableSsl = true;
            mail = new MailMessage();
            String[] addr = TextBox1.Text.Split(',');
            try
            {
                mail.From = new MailAddress("user gmail", "test", System.Text.Encoding.UTF8);
                Byte i;
                for( i = 0;i< addr.Length; i++)
                    mail.To.Add(addr[i]);
                mail.Subject = TextBox3.Text;
                mail.Body = TextBox4.Text;
                if(ListBox1.Items.Count != 0)
                {
                    for(i = 0;i<ListBox1.Items.Count;i++)
                    mail.Attachments.Add(new Attachment(ListBox1.Items[i].ToString()));
                }
                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                mail.ReplyTo = new MailAddress(TextBox1.Text);
                SmtpServer.Send(mail);
            }
            catch (Exception ex)
            {
            MessageBox.Show(ex.ToString());
            }





User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 08:04PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month