Search code examples
c#smtpexchangewebservicesjournaling

How to add multiple e-mail recipients in a mail , but send the mail to only a selected few addresses?


I am building an app for journaling purpose , were I will put all messages in an e-mail and will send it to a journaling mailbox . What I want is to display the email addresses of all the recepients of original messages in to field but not actually send them any mail. For example if a message was sent to "[email protected]" then on journaling I want to display "[email protected] " in to field of journaling mail but not actually send this mail to "[email protected]" I am coding this application in c#, is there any way to achieve this?


Solution

  • Here is a sample of SMTP commands (from Wikipedia) that are used when sending a mail:

    HELO relay.example.org
    MAIL FROM:<[email protected]>
    RCPT TO:<[email protected]>
    RCPT TO:<[email protected]>
    DATA
    From: "Bob Example" <[email protected]>
    To: Alice Example <[email protected]>, John Example <[email protected]>, Jane Example <[email protected]>
    Cc: [email protected]
    Date: Tue, 15 January 2008 16:02:43 -0500
    Subject: Test message
    
    My Test message.
    .
    QUIT
    

    The real recipients of this email are specified by the command RCPT TO. Then in the DATA command, which contains the content of your mail and some headers such as From, To, Subject,... You can specify whatever you want in those headers (including From and To).

    So you put all the original recipients in the To header. And you add only your journaling mailbox with the RCPT TO command. This will send the mail only to your journaling mail box, but all the recipients will be displayed in the To header of the mail when you open it.