Click here to Skip to main content
15,901,853 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using the
SmtpClient
to send automated emails in my application.

When I specify the "To Address" and a "CC Address" that are the same, the SMTP Client class throws the following exception:
Bad sequence of commands. The server response was: 5.5.0 Recipient already specified


I do not understand this error. I can manually write an email where the "To" and "CC" are the same.

What I have tried:

I have searched for this error on the web and cannot find anything.
Posted
Comments
Andre Oosthuizen 8-May-24 12:40pm    
Please show us your code you are using to understand where your code errors. As it stands now it is a question in the dark.
Kevin Brady 8-May-24 12:54pm    
It is too long to post here.

1 solution

Seriously? It's telling you is that you have duplicate recipients. Just remove the duplicated recipients and the error goes away.

It is absolutely useless to send an email to the same user using both the TO field and the CC field, so just don't put the user emails in both fields.

You can do it in your email client because the client is filtering out the duplicated addresses when it posts the message to the server.
 
Share this answer
 
Comments
Kevin Brady 8-May-24 12:57pm    
I disagree that it is "absolutely useless". And I don't understand why the smtp client should even care.

This is being implemented programmatically. Now I have to insert a check for it for duplicates.
Dave Kreskowiak 8-May-24 12:58pm    
Why on earth would you specify the same email address twice in two different fields? I just don't see the reason for it.

You're not disagreeing with me. You're disagreeing with the server. You have to follow its rules, not mine.
Kevin Brady 8-May-24 13:04pm    
Dave, Thanks for your help on this topic. I agree, I am not disagreeing with you.
One possible reason is that some email users filter their inbox based on whether they are "To" recipients or "cc" recipients.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900