Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Send emails with WPF

 

With the following code sample you can easily send emails in WPF applications

 

 

Please adjust or change variables in the code:

 

To do this you have to set variables or swap them in the C # code

app_settings._Smtp_User 

app_settings._smtp_password

 

the call parameters:

string sTitle, string sText

 

the receiver

app_settings._admin_email

 

and the visible sender

app_settings._Smtp_User, "Search Agent"

 

Code Sample: send emails

using System;

 

using System.Threading.Tasks;           //*async

using System.Net.Mail;                  //*smtp client

using System.Net;                       //*Network Credential

//using Windows.ApplicationModel.Email;   //*email

 

public static class clsEmail

{

    //============< clsEmail >============

    public static bool send_Email(string sTitle, string sText)

    {

        //------------< send_Email() >------------

        //send email with uwp and smtp-server

        //< email >

        MailMessage email = new MailMessage();

        email.To.Add(app_settings._admin_Email);

        email.From = new MailAddress(app_settings._Smtp_User, "Searchagent");

        email.Subject = sTitle;

        email.Body = sText;

        //</ email >

 

        //< email-server >

        SmtpClient client = new SmtpClient();

        client.Host = app_settings._Smtp_Server;

        client.UseDefaultCredentials = false;

        client.DeliveryMethod = SmtpDeliveryMethod.Network;

        //< no ssl >

        client.Port = 25;

        client.EnableSsl = false;

        //</ no ssl >

 

        //< ssl >

        //*securesmpt.t-online.de

        //client.Port = 587;

        //client.EnableSsl = true;

        //</ ssl >

        client.Credentials = new NetworkCredential(app_settings._Smtp_User, app_settings._Smtp_Password);

        //</ email-server >

 

        //< send >

        //await client.SendMailAsync(email);      //*no error message

        client.Send(email);                       //*with error message

                                                  //</ send >

 

        return true;

        //------------</ send_Email() >------------

    }

    //============</ clsEmail >============

}

 

 

 

Mobile
»
Read text from PDF using iTextSharp
»
Send emails with WPF
»
C # Application: Webrobot to read all Ebay Kleinanzeigen
»
WPF: Navigate to a page
»
WPF: create a selectable list
»
WPF: Set Startup Window
»
Add WPF Local SQL Database to Application and Connect Data
»
WPF / UWP: Canvas with relative positions and sizes
»
C #, WPF, UWP: ScreenShot to save an app or window area as a file
»
C #: Windows ScreenShot save as file

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de