locked
Show an email as being sent to multiple recipients - but has actually been sent to each recipient individually. RRS feed

  • Question

  • I am writing an add-in for Outlook 2007 to solve an issue a client has when sending out emails via a distributin list (which can have any where between 10 - several hundred recipients).

    The add-in takes the email written by the user, looks up and resolves the recipients and then removes any duplicate email addresses.

    The add-in then sends an individual email to each recipient, but does not place a copy of the sent email in the Sent Items Folder (so not too fill up the Sent Items Folder with hundreds of emails).

    Once an email has been sent to all of the recipients, I would like to place one copy of the email sent, in the Sent Items Folder, but showing all recipients (as the email was first drafted, eg showing Distribution List names etc).

    I have managed to do this to a degree, by moving the original email to the sent items folder, but there is no date/time entry recorded in the mail item.  The 'SentOn' property of the email is 'Read Only' and can not be changed.

    Does any one know of a way, where I can get a copy of the sent email into the Sent Items folder, showing all the original recipents and a date of when it was sent.

    Any help will be greatly appriciated.

    Saturday, November 28, 2009 5:07 PM

Answers

  • Hello again Simon,

    <<I know the SentOn field of the mailitem is read-only, and can not be changed.  But there is usualy more than one way to do things, and there must be some process to change the date field.>>
    Since this original mail with multiple recipients has not been sent by clicking Send button. So the SentOn property of this mail is set to a default value "1/1/4501 12:00:00 AM". Once it is send successfully, SentOn property is set to the time when this mail is sent. For SentOn perperty, please refer to this MSDN page. It says " When you send an item using the object's Send method, the transport provider sets the ReceivedTime and SentOn properties for you."

    As far as I know, outlook object model does not expose any method/property to change a read-only property. I think you could leave a mail which has been sent to a recipient in Sent Items folder. And then move this original mail to Sent Items folder. However, I know this is not a best method.

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bessie Zhao Monday, December 7, 2009 10:29 AM
    Wednesday, December 2, 2009 3:42 AM

All replies

  • Hello,

    Based on my understanding, the scenario is as below,

    1. User sends an email A to multiple recipients by UI, Then this mail is stored in Sent Items folder.
    2. Now you want to send an email to each recipient according to email A. The email's body is as the same as email A.

    If yes, I think you could use create a new email and copy the body of email A. And then send it. As for the email A, we could use ItemAdd event of Sent Items folder to listen every sent email, and ten pick this mail use depending on recipients or some else condition. To create a new email, please use CreateItem method [See: Application.CreateItem Method]. For ItemAdd event, please refer to this MSDN article: Items.ItemAdd Event.

    If I have mistaken this scenario, please point me out.

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, December 1, 2009 6:07 AM
  • Bessie,

    Thanks for the time in reading and replying  my question.

     The process is as follows;

    The user composes an email as normal.

    Instead of clicking the send button to send to all recipients in the To, Cc & Bcc fields at once, my add-in has it's own button that does the following.

    1. User creates their email in the usual way.
    2.  The entries in the To, Cc & Bcc fields are checked for validitity.
    3.  Each recipient is checked to see what type of Recipient it is (Exchange, SMTP or Private Distribution List (MAPIPDL)
    4.  If the recipient type is a MAPIPDL item, then it's members SMTP or Exchange email addresses are retreived.
    5.  Any MAPIPDL items within a MAPIPDL item are also checked (as in process 4)
    6.  The reutrned emails are then checked for duplicates (any duplicates are discarded).
    7.  For each email address returned, a copy of the email is created and sent to that email address.  A copy of this email is NOT moved to the Sent Items Folder, it is deleted after being sent.  This is so the Sent Items Folder does not fill up with hundreds of sent email items.
    8.  The original email (with the original recipients, DistLists etc) is moved to the Sent Items Folder BUT (THIS IS THE BIT I CAN NOT DO) I want to show the time it was moved there as the SentTime (eg, so it looks like one email was sent to many recipients). 

    I know the SentOn field of the mailitem is read-only, and can not be changed.  But there is usualy more than one way to do things, and there must be some process to change the date field.

    I will look at the links you mentioned above.  Any help on setting the SentOn field of the sent mailitem, or a method to simulate this would be greatly appriciated.

    Regards

    Simon



    Tuesday, December 1, 2009 9:52 AM
  • Hello again Simon,

    <<I know the SentOn field of the mailitem is read-only, and can not be changed.  But there is usualy more than one way to do things, and there must be some process to change the date field.>>
    Since this original mail with multiple recipients has not been sent by clicking Send button. So the SentOn property of this mail is set to a default value "1/1/4501 12:00:00 AM". Once it is send successfully, SentOn property is set to the time when this mail is sent. For SentOn perperty, please refer to this MSDN page. It says " When you send an item using the object's Send method, the transport provider sets the ReceivedTime and SentOn properties for you."

    As far as I know, outlook object model does not expose any method/property to change a read-only property. I think you could leave a mail which has been sent to a recipient in Sent Items folder. And then move this original mail to Sent Items folder. However, I know this is not a best method.

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bessie Zhao Monday, December 7, 2009 10:29 AM
    Wednesday, December 2, 2009 3:42 AM