ms form send email
derek chan
1
Reputation point
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
2 answers
Sort by: Most helpful
-
-
Karen Payne MVP 35,436 Reputation points
2021-08-26T20:46:54.13+00:00 The SmtpClient class is not recommended as per Microsoft
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