How to inject "RCPT TO" using ComponentPro.Net.Mail

0
Hi I have a number of EML files that I need to send to a vendor. I have been advised to make no changes to the EML ("To" field) to send the files but to inject the below: > RCPT TO:<> Below is the code I am using, which is not working (I did not expect to): using (Smtp smtpClient = new Smtp()) { smtpClient.CommandResponse = SmtpClient_CommandResponse; smtpClient.Connect(smtpArchiveDestination.Server); smtpClient.Authenticate(smtpArchiveDestination.Username, smtpArchiveDestination.Password); smtpClient.SendCommand($"RCPT TO:{smtpArchiveDestination.EmailAddress}"); smtpClient.Send(EML); smtpClient.Disconnect(); } What do I need to do to inject the "RCPT TO", please? Thank you DK
 
asked 7/23/2021 7:04:43 PM
add a comment

2 Answers

0
Hi Have you checked this [Send][1] ,it will allow you to use [SmtpSendOptions ][2] it has members like [config][3] which will allow you send files with smtp settings of your choice. [1]: https://doc.componentpro.com/ComponentPro-Mail/ComponentPro-Net-Mail-Smtp-Send(System-String,ComponentPro-Net-Mail-SmtpSendOptions) [2]: https://doc.componentpro.com/ComponentPro-Mail/ComponentPro-Net-Mail-SmtpSendOptions [3]: https://doc.componentpro.com/ComponentPro-Mail/ComponentPro-Net-Mail-SmtpSendOptions~Members
 
answered 8/6/2021 5:40:01 PM
add a comment
0
Hi Daraius, Please use the below code and also apply exception handling to know details of the exception. using System; using System.ComponentModel; using ComponentPro; using ComponentPro.Net.Mail; ... public void DoSendCommandAsync() { // Create a new instance of the Smtp class. Smtp client = new Smtp(); // Connect to the server. client.Connect("myserver"); // Or you can specify the SMTP port with // client.Connect("myserver", 25); // Login to the server. client.Authenticate("user", "password"); // ... // Register an event handler. client.SendCommandCompleted = client_SendCommandCompleted; client.ReadResponseCompleted = client_ReadResponseCompleted; // Send 'HELP' command to the server. client.SendCommandAsync("HELP", false); // ... // Disconnect. client.Disconnect(); } void client_ReadResponseCompleted(object sender, ExtendedAsyncCompletedEventArgs e) { Smtp client = (Smtp)sender; try { // Print out the response. Console.WriteLine(e.Result.RawResponse); } catch (Exception exc) { Console.WriteLine("Error: " exc.ToString()); } } void client_SendCommandCompleted(object sender, AsyncCompletedEventArgs e) { Smtp client = (Smtp)sender; if (e.Error != null) { Console.WriteLine("Error: " e.Error.ToString()); } else { // Asynchronously read response from the server. client.ReadResponseAsync(); } }
edited 7/27/2021 3:17:37 AM
answered 7/27/2021 3:16:05 AM
  Hi Martin, thank you but this did not work for me. I have an email to send, but I need to set the "RCPT TO" before the email is sent. How do I do this, please? Daraius 8/4/2021 3:47:07 PM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged mail smtp or ask your own question.