Spire.Email for .NET is a professional .NET Email library specially designed for developers to create, read and manipulate emails from any .NET (C#, VB.NET, ASP.NET) platform with fast and high quality performance.

Thu Jul 06, 2023 1:54 am

Hi.

When using Spire.email, can I send mail to an account that does not exist in my PC's Outlook profile?
The mail should exist in that account's Sent message box.

When using `outlook.interop`, if the account does not exist in the mail profile of the PC, it cannot be sent.

Sungkyu_min
 
Posts: 35
Joined: Fri Jan 07, 2022 5:53 am

Thu Jul 06, 2023 7:37 am

Hello,

Thanks for your inquiry.
When using Spire.Email to send emails, you can send an email to any valid recipient email address, even if that recipient's email address does not exist in your computer's Outlook profile. The example code is as follows.
Code: Select all
  MailAddress addressFrom = new MailAddress("from@outlook.com", "Name");
            MailAddress addressTo = new MailAddress("To@outlook.com");
            MailMessage message = new MailMessage(addressFrom, addressTo);

            message.Date = DateTime.Now;
            message.Subject = "test";
            string htmlString = @"
<html>
<body>
<p>Hello!</p>
<p>This is used for testing<br>Z<br>2023.7.6</p>
</body>
</html>";
            message.BodyHtml = htmlString;
            //SmtpClient
            SmtpClient client = new SmtpClient();
            client.Host = "smtp.outlook.com";
            client.Port = 587;
            client.Username = addressFrom.Address;
            client.Password = "****";
            client.ConnectionProtocols = ConnectionProtocols.Ssl;

            client.SendOne(message);

If you have any other questions or concerns, please feel free to contact us anytime.

Sincerely
Wenly
E-iceblue support team
User avatar

Wenly.Zhang
 
Posts: 149
Joined: Tue May 16, 2023 2:19 am

Return to Spire.Email