ms form send email

derek chan 1 Reputation point
2021-08-26T08:54:47.05+00:00

I want to create a form , the form have a pull-down menu as below , what I want to do is when select from the menu option , for example , select peter , then send a email to peter's email , is it ok to do that ?

thanks

pull-down menu
peter
mary
amy

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,873 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 83,206 Reputation points
    2021-08-26T09:24:58.583+00:00
    0 comments No comments

  2. Karen Payne MVP 35,386 Reputation points
    2021-08-26T20:46:54.13+00:00

    The SmtpClient class is not recommended as per Microsoft

    126904-mailgone.png

    Use MailKit via NuGet.

    C#

    using System;  
    using MailKit.Net.Smtp;  
    using MailKit;  
    using MimeKit;  
      
    namespace TestClient  
    {  
    	internal class Program  
    	{  
    		public static void Main(string[] args)  
    		{  
    			var message = new MimeMessage();  
    			message.From.Add(new MailboxAddress("Joey Tribbiani", "joey@friends.com"));  
    			message.To.Add(new MailboxAddress("Mrs. Chanandler Bong", "chandler@friends.com"));  
    			message.Subject = "How you doin'?";  
      
    			message.Body = new TextPart("plain") {Text = "Hey Chandler,  I just wanted to let you know that Monica and I were going to go play some paintball, you in?  -- Joey"};  
      
    			using (var client = new SmtpClient())  
    			{  
    				client.Connect("smtp.friends.com", 587, false);  
      
    				// Note: only needed if the SMTP server requires authentication  
    				client.Authenticate("joey", "password");  
      
    				client.Send(message);  
    				client.Disconnect(true);  
    			}  
    		}  
    	}  
    }  
    

    VB

    Option Infer On  
    Imports System  
    Imports MailKit.Net.Smtp  
    Imports MailKit  
    Imports MimeKit  
      
    Namespace TestClient  
    	Friend Class Program  
    		Public Shared Sub Main(ByVal args() As String)  
    			Dim message = New MimeMessage()  
    			message.From.Add(New MailboxAddress("Joey Tribbiani", "joey@friends.com"))  
    			message.To.Add(New MailboxAddress("Mrs. Chanandler Bong", "chandler@friends.com"))  
    			message.Subject = "How you doin'?"  
      
    			message.Body = New TextPart("plain") With {.Text = "Hey Chandler,  I just wanted to let you know that Monica and I were going to go play some paintball, you in?  -- Joey"}  
      
    			Using client = New SmtpClient()  
    				client.Connect("smtp.friends.com", 587, False)  
      
    				' Note: only needed if the SMTP server requires authentication  
    				client.Authenticate("joey", "password")  
      
    				client.Send(message)  
    				client.Disconnect(True)  
    			End Using  
    		End Sub  
    	End Class  
    End Namespace