Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Mail;
- using System.Text;
- using System.Threading.Tasks;
- namespace poslaniemalu
- {
- class Program
- {
- static void Main(string[] args)
- {
- // try
- // {
- // MailMessage m = new MailMessage("martin.bielik10@mail.com", "martin.bielik10@mail.com");
- // m.Subject = "nothing";
- // m.Body = "nothing";
- // m.IsBodyHtml = true;
- // m.From = new MailAddress("martin.bielik10@mail.com");
- // m.To.Add(new MailAddress("martin.bielik10@mail.com"));
- // SmtpClient smtp = new SmtpClient();
- // smtp.Port = 25;
- // smtp.Host = "Gate33.gw.tietoenator.com";
- // NetworkCredential authinfo = new NetworkCredential("martin.bielik10@mail.com", "moje heslo");
- // smtp.UseDefaultCredentials = false;
- // smtp.Credentials = authinfo;
- // smtp.Send(m);
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine(ex.ToString());
- // }
- SendMail("martin.bielik10@gmail.com", "martin.bielik10@gmail.com",null,"tralala","nothing");
- Console.ReadKey();
- }
- public static string SendMail(string toList, string from, string ccList, string subject, string body)
- {
- MailMessage message = new MailMessage();
- SmtpClient smtpClient = new SmtpClient();
- string msg = string.Empty;
- try
- {
- MailAddress fromAddress = new MailAddress(from);
- message.From = fromAddress;
- message.To.Add(toList);
- if (ccList != null && ccList != string.Empty)
- message.CC.Add(ccList);
- message.Subject = subject;
- message.IsBodyHtml = true;
- message.Body = body;
- smtpClient.Host = "Gate33.gw.tietoenator.com"; // We use gmail as our smtp client
- smtpClient.Port = 25;
- //smtpClient.EnableSsl = true;
- //smtpClient.UseDefaultCredentials = true;
- //smtpClient.Credentials = new System.Net.NetworkCredential("martin.bielik10@gmail.com", "moje heslo");
- smtpClient.Send(message);
- msg = "Successful<BR>";
- }
- catch (Exception ex)
- {
- msg = ex.Message;
- }
- return msg;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement