Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

windowsform mail sender app

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void btnTest_Click(object sender, RoutedEventArgs e)
    {
        MailAddress from = new MailAddress("Someone@domain.topleveldomain", "Name and stuff");
        MailAddress to = new MailAddress("Someone@domain.topleveldomain", "Name and stuff");
        List<MailAddress> cc = new List<MailAddress>();
        cc.Add(new MailAddress("Someone@domain.topleveldomain", "Name and stuff"));
        SendEmail("Want to test this damn thing", from, to, cc);
    }

    protected void SendEmail(string _subject, MailAddress _from, MailAddress _to, List<MailAddress> _cc, List<MailAddress> _bcc = null)
    {
        string Text = "";
        SmtpClient mailClient = new SmtpClient("Mailhost");
        MailMessage msgMail;
        Text = "Stuff";
        msgMail = new MailMessage();
        msgMail.From = _from;
        msgMail.To.Add(_to);
        foreach (MailAddress addr in _cc)
        {
            msgMail.CC.Add(addr);
        }
        if (_bcc != null)
        {
            foreach (MailAddress addr in _bcc)
            {
                msgMail.Bcc.Add(addr);
            }
        }
        msgMail.Subject = _subject;
        msgMail.Body = Text;
        msgMail.IsBodyHtml = true;
        mailClient.Send(msgMail);
        msgMail.Dispose();
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: index was out of the bound array in c# 
Csharp :: two question marks together mean in C# 
Csharp :: wpf string to byte array 
Csharp :: c# how to output array 
Csharp :: open and close autocad api 
Csharp :: .net core not returning the sub list 
Csharp :: asp.net mvc class="" inline select 
Csharp :: catwherehouse 
Csharp :: telerik mvc grid unbound column 
Csharp :: c# supplier equivalent 
Csharp :: sterge element din coada c# 
Csharp :: How to do a comment in c# 
Csharp :: initialize c# array property of class object site:stackoverflow.com 
Csharp :: design pattern for so many conditions c# 
Csharp :: gersener waves 
Csharp :: what is vector3.one c# 
Csharp :: unity how to have multiple headers 
Csharp :: how to download things c# 
Csharp :: number to string ef example c# 
Csharp :: attribute decorator to require email format of string c# 
Csharp :: how to read reportview query string asp.net c# 
Csharp :: in model add to give drop down message 
Csharp :: export xml 
Csharp :: blazor OnInitializedAsync Unhandled exception rendering component: Cannot wait on monitors on this runtime. 
Csharp :: C# predict rotation by an angular velocity 
Csharp :: best programming language for compression ratio 
Csharp :: Get mac address of Device - NAYCode.com 
Csharp :: go down a line in function documentation 
Csharp :: unity rotatoin angle 
Csharp :: secret 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =