none
Sent column in the drafts folder. SentOn date in the MailItem of Outlook object model RRS feed

  • Question

  • Background:

    2 Weeks ago our Exchange server was migrated from 2003 to 2013.

    I am a developer at a company which develops software which integrates with outlook

    After the upgrade, the software suddenly stopped being able to open draft emails. This was never an issue for us before the migration happened.

    I managed to track this down to a bit of old code that checked the SentOn property of the draft MailItem before it opened it, which now seems to have a sent date which is different to 4501/01/01 ( which I believe was the old default?).

    Based on this date being set, the code path changes to open the item as a Sent MailItem, which means that any further changes which are made to the so called 'draft' are not retained, this resulted in a lot of blank emails being sent, and a lot of unhappy people.

    Information:

    Issue occurs in Outlook 2010, Outlook 2013 and Outlook 2016 (these I have confirmed and tested)

    Connection to exchange is with cached exchange mode OFF. It cannot be turned on in our terminal server environment.

    Outside of the terminal server environment with cached exchange mode ON, this issue does not exist. With it turned off, the issue is exactly the same as the terminal server experience.

    Note:

    Obviously there has been 10 years between the exchange server versions we have used, so as far as I know this issue could have appeared at any time during that, but I do not have any way of narrowing down the time at which this issue may have started.

    Couple of questions:

    1. Why is there a sent column in the drafts folder inside of outlook? is this not the most absurd thing ever? A draft with a sent date? Was this because people complained about ordering their drafts folder so often? (google the issue and you will see this) - this really frustrates me when I see it.

    2. What difference is there between Outlook connecting to exchange 2003 to exchange 2013 with regard to creating and saving a draft email into the draft folder? (I'm only using the outlook buttons, not any external software or code) - a draft created when connected to exchange 2003 would have the sent date column populated with 'None'. With exchange 2013 it seems to use the created date, This only happens with cached exchange mode OFF. With it ON, the draft email saves to the draft folder with the sent date 'None', the same as the old Outlook2013 to exchange 2003 did ( but that used to do it with cached exchange mode OFF)

    3. Am I missing a setting somewhere in outlook or on the exchange server which enables this functionality?

    TLDR

    Outlook2010 - 2016 to exchange 2003 cached exchange mode on - Draft created with NONE in sent column

    Outlook2010 - 2016 to exchange 2003 cached exchange mode off - Draft created with NONE in sent column

    Outlook2010 - 2016 to exchange 2013 cached exchange mode on - Draft created with NONE in sent column

    Outlook2010 - 2016 to exchange 2013 cached exchange mode off - Draft created with DATE in sent column

    Why the difference?

    Wednesday, November 4, 2015 10:12 AM

Answers

  • - Microsoft have confirmed this as a BUG

    To all who are interested;

    I have been able to get into contact with Microsoft, explaining the problem and linking this forum post to my query regarding sent on dates. I had also provided then screenshots detailing the issue and the responses were as follows;

      

    --------------------------------------##START OF EMAIL##----------------------------------------------------------------------------

    Hello Jordan,

    Thank you for contacting Microsoft Support. My name is Nadeem Khan.  I am the Support Professional who will be working with you on this Service Request. You may reach me using the contact information listed below, referencing the SR number 615111394342190 - Draft emails have sent dates.

    I am providing you a copy of our scope agreement for your issue.

    Issue Definition: Draft emails have sent dates.

    Scope Agreement: Once we are able to resolve this issue or we can rule out the issue  as third party in nature or a product limitation we will consider the case to be resolved and closed.
    We will further begin working together to resolve this issue. If you believe the scope defined above is not specific to your issue or would like to amend it, please let me know.

    Regards,

    Nadeem Khan - Microsoft Online Services Technical Support.

    --------------------------------------##END OF EMAIL##----------------------------------------------------------------------------

    And then I had a follow up email when I did not responded;

    --------------------------------------##START OF EMAIL##---------------------------------------------------------------------------- 

    Hello Jordan,

    I tried calling you, however unable to reach you hence left a message. 

    I want to inform you that your issue has been filed as a bug and we don't know when the ETA will be relased.

    Hence we will be Archiving the case.

    Looking forward to your reply.

    Mohammed Shoaib

    Outlook Support Engineer

    --------------------------------------##END OF EMAIL##----------------------------------------------------------------------------

         

    My response...

    --------------------------------------##START OF EMAIL##----------------------------------------------------------------------------

    Hello Mohammed,

    Thank you for getting back to me regarding this issue, and apologies to Nadeem Khan  for not responding to the previous correspondence. This is not my primary email address and is purely used for development purposes. You will be able to reach me at - ********** - if this is easier for you.

    I've also updated my contact details for the development account, so there are now two phone numbers that you can also contact me on, these are listed below;
    +44 782*******
    +44 780*******

    My working hours are 9-5:30 GMT and this would be the best time to call if it is required that you do so.

    I am concerned however that Microsoft is ignoring the issue that you have acknowledged as a bug and I wonder what you mean when you say it will be Archived? - Will the issue be investigated any further or will this be the end of it?

    Thank you again

    Kind Regards,
    Jordan Robins

    --------------------------------------##END OF EMAIL##----------------------------------------------------------------------------

    Final response from msft...

    --------------------------------------##START OF EMAIL##----------------------------------------------------------------------------

    Hello Jordan,

    We are not ignoring the issue Microsoft is looking into it.

    The fix will be released as an update and once you install it, it will be fixed.

    But we do not have any ETA on when will the update be released.

    Mohammed Shoaib

    Outlook Support Engineer

    --------------------------------------##END OF EMAIL##----------------------------------------------------------------------------

    So there we go, it will be fixed, it is a bug, and now Microsoft are aware of it.

    Thanks to everyone who has spent time reading these posts and/or looking it as well.

    • Marked as answer by JordanRobins Thursday, December 3, 2015 9:11 AM
    Thursday, December 3, 2015 9:11 AM

All replies

  • What is the value returned by SentOn? How does your code check that value? Never use "=" with date/time properties, the condition might not be satisfied due to the roundoff errors.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, November 6, 2015 7:45 PM
  • Thank you for your reply Dmitry.

    One bit of code was :

      

    Public Function Outlook_MSG_Sent_Date(byval pstrDocumentFilePath as String) As Date

    On Error GoTo ErrorHandler Dim dtResult As Date = Nothing Dim rdoSession As Object Dim rdoItem As Object rdoSession = CreateObject("Redemption.RDOSession") rdoSession.MAPIOBJECT = gOutlookobj.Session.MAPIOBJECT 'This is the outlook application object rdoItem = rdoSession.GetDefaultFolder(16).Items.Add(0) rdoItem.Import(pstrDocumentFilePath, 3)

    rdoItem.Save() If IsDate(rdoItem.SentOn) = False Or rdoItem.SentOn = CDate("4501/01/01") Then Else dtResult = rdoItem.SentOn End If FunctionExit: On Error Resume Next If rdoItem IsNot Nothing Then rdoItem.Delete() End If rdoItem = Nothing rdoSession = Nothing Return dtResult Exit Function ErrorHandler: Dim lngErrNumber As Long Dim strErrDescription As String lngErrNumber = Err.Number strErrDescription = Err.Description Err.Clear() CreateLogEntry(App6.EXEName, "Error", "Outlook_MSG_IsSent", "An error occurred when trying to determine the Sent Date on an MSG file, error number: " & lngErrNumber & " description: " & strErrDescription) Resume FunctionExit End Function

    This suddenly started returning dates instead of nothing when giving it the path of a draft email.

    Another bit of Code started incorrectly determining Draft emails were no longer draft emails, and thus, they were not being opened:

    Public Function OpenDraftEmail(ByVal pstrDocumentFilePath As String) As Boolean
    
      On Error GoTo ErrorHandler
      
      Dim strEntryId As String
      Dim strParentFolderID As String
    
      Dim rdoSession As Object
      Dim rdoItem As Object
      Dim olItem As Object
    
      Dim blnResult As Boolean = False
    
      rdoSession = CreateObject("Redemption.RDOSession")
    
      If IsOutlookRunning() = True Then
         If rdoSession Is Nothing = False Then
          rdoSession.MAPIOBJECT = gOutlookObj.Session.MAPIOBJECT
          rdoItem = rdoSession.GetDefaultFolder(16).Items.Add(0)
          
          rdoItem.Import(pstrDocumentFilePath, 3)
          rdoItem.Save()
    
          strEntryId = rdoItem.EntryID
          strParentFolderID = rdoItem.Parent.StoreID
          
          rdoItem = Nothing
          rdoSession = Nothing
    
          olItem = gOutlookObj.Session.GetItemFromID(strEntryId, strParentFolderID)
    
          If olItem Is Nothing = False Then
            If IsDate(olItem.SentOn) = False Or olItem.SentOn = CDate("4501/01/01") Then
              blnResult = True
              olItem.Display()
            Else
              'this appears to not be a draft item
              olItem.Close(0)
              olItem.Delete()
            End If
          End If
        End If
      End If
    
    FunctionExit:
      Return blnResult
      
      Exit Function
    
    ErrorHandler:
      Dim varErrNumber As Object = Err.Number
      Dim varErrDescription As Object = Err.Description
    
      Err.Clear()
    
      On Error Resume Next
    
      Call CreateLogEntry(My.Application.Info.Title, "Error", "OpenDraftEmail", "Error Number: " & varErrNumber & ControlChars.CrLf & "Error Description: " & varErrDescription)
    
      blnResult = False
      Resume FunctionExit
    End Function

    Both the redemption mail item in the first procedure, and the outlook mail item in the second procedure were found to have a SentOn date in the bit of code checking for it.

    A SentOn date that was a date, and also not equal to 4501/01/01 (Which I am to believe is the default date that used to be given to this SentOn field, while it was a draft) meant that both of these procedures were working incorrectly after moving exchange server version and working with draft emails

    Monday, November 9, 2015 9:22 AM
  • >>>Outlook2010 - 2016 to exchange 2013 cached exchange mode on - Draft created with NONE in sent column
    Outlook2010 - 2016 to exchange 2013 cached exchange mode off - Draft created with DATE in sent column<<<

    Base on my testing, when exchange 2013 cached exchange mode on and off, Draft always created with DATE in sent column, you could refer to below :

    cachedon.JPG 

    Create Draft with Date 1/1/4501:

    msgOn.JPG 

    cachedOff.JPG 

    Create Draft with Date 1/1/4501:

    msgOff.JPG 

    But when you change cached Exchange mode on to off, you will find Draft sendon date has been changed, you could refer to below :

    change.JPG 

    These code is my test codes:

    On Error Resume Next
    
        Dim objNS As Outlook.NameSpace
        Dim objSentItemsFolder As Outlook.MAPIFolder
        Dim myItem As Outlook.MailItem
    
        Set objNS = Application.GetNamespace("MAPI")
        Set objDraftItemsFolder = objNS.GetDefaultFolder(olFolderDrafts)
    
        For Each myItem In objDraftItemsFolder.Items
            If TypeOf myItem Is MailItem Then
                 MsgBox myItem.SentOn & Chr(10) & _
                        Format(myItem.SentOn, "MMM d, yyyy")
            End If
         Next myItem
    
        Set objNS = Nothing
        Set objSentItemsFolder = Nothing
        Set myItem = Nothing
    

    For more information, click here to refer about Turn on Cached Exchange Mode

    Based on the testing, it sees that the issue was caused by switching cached Exchange mode from "off" to "on".

    So I suggest that you could consider to contact the Microsoft Professional Support at the same time so that our engineers could work closely with you to resolve this issue as soon as possible.

    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophones

    Thanks for your understanding.

    Friday, November 13, 2015 9:10 AM
  • Hello Friends,

    Since look like this is an active thread, i am asking my question here which is related to this date issue. Is there any possibility that mailItem.SentOn property would return same date but different time? e.g. 4501-01-01T02:55:59 instead of 4501-01-01T12:00:00

    Thanks in advance.


    sureshh...

    Wednesday, December 2, 2015 4:39 PM
  • No, it will always be 1/1/4501.

    But it should not matter as you should never compare dates using "=" (or == in C#/C++). Extract the year / month / day, and compare them.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, December 2, 2015 8:43 PM
  • Thanks Dmitry for the quick response. But look like unfortunately it is happening at one of our user's machine somehow. We have code like this at our end and it recorded time as "4501-01-01T02:55:59"

    DateTime SENT_ON_DATE = new DateTime(4501, 1, 1, 0, 0, 0);

    return (mailItem.SentOn == SENT_ON_DATE ? DateTime.Now() : mailItem.SentOn);


    So do you mean we should not really have check like (mailItem.SentOn == SENT_ON_DATE)? and instead extract  year/month and day and then compare it? Please confirm.

    Thanks again.


    sureshh...

    Wednesday, December 2, 2015 11:04 PM
  • That is correct. Extract Year, month, day.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, December 3, 2015 12:01 AM
  • - Microsoft have confirmed this as a BUG

    To all who are interested;

    I have been able to get into contact with Microsoft, explaining the problem and linking this forum post to my query regarding sent on dates. I had also provided then screenshots detailing the issue and the responses were as follows;

      

    --------------------------------------##START OF EMAIL##----------------------------------------------------------------------------

    Hello Jordan,

    Thank you for contacting Microsoft Support. My name is Nadeem Khan.  I am the Support Professional who will be working with you on this Service Request. You may reach me using the contact information listed below, referencing the SR number 615111394342190 - Draft emails have sent dates.

    I am providing you a copy of our scope agreement for your issue.

    Issue Definition: Draft emails have sent dates.

    Scope Agreement: Once we are able to resolve this issue or we can rule out the issue  as third party in nature or a product limitation we will consider the case to be resolved and closed.
    We will further begin working together to resolve this issue. If you believe the scope defined above is not specific to your issue or would like to amend it, please let me know.

    Regards,

    Nadeem Khan - Microsoft Online Services Technical Support.

    --------------------------------------##END OF EMAIL##----------------------------------------------------------------------------

    And then I had a follow up email when I did not responded;

    --------------------------------------##START OF EMAIL##---------------------------------------------------------------------------- 

    Hello Jordan,

    I tried calling you, however unable to reach you hence left a message. 

    I want to inform you that your issue has been filed as a bug and we don't know when the ETA will be relased.

    Hence we will be Archiving the case.

    Looking forward to your reply.

    Mohammed Shoaib

    Outlook Support Engineer

    --------------------------------------##END OF EMAIL##----------------------------------------------------------------------------

         

    My response...

    --------------------------------------##START OF EMAIL##----------------------------------------------------------------------------

    Hello Mohammed,

    Thank you for getting back to me regarding this issue, and apologies to Nadeem Khan  for not responding to the previous correspondence. This is not my primary email address and is purely used for development purposes. You will be able to reach me at - ********** - if this is easier for you.

    I've also updated my contact details for the development account, so there are now two phone numbers that you can also contact me on, these are listed below;
    +44 782*******
    +44 780*******

    My working hours are 9-5:30 GMT and this would be the best time to call if it is required that you do so.

    I am concerned however that Microsoft is ignoring the issue that you have acknowledged as a bug and I wonder what you mean when you say it will be Archived? - Will the issue be investigated any further or will this be the end of it?

    Thank you again

    Kind Regards,
    Jordan Robins

    --------------------------------------##END OF EMAIL##----------------------------------------------------------------------------

    Final response from msft...

    --------------------------------------##START OF EMAIL##----------------------------------------------------------------------------

    Hello Jordan,

    We are not ignoring the issue Microsoft is looking into it.

    The fix will be released as an update and once you install it, it will be fixed.

    But we do not have any ETA on when will the update be released.

    Mohammed Shoaib

    Outlook Support Engineer

    --------------------------------------##END OF EMAIL##----------------------------------------------------------------------------

    So there we go, it will be fixed, it is a bug, and now Microsoft are aware of it.

    Thanks to everyone who has spent time reading these posts and/or looking it as well.

    • Marked as answer by JordanRobins Thursday, December 3, 2015 9:11 AM
    Thursday, December 3, 2015 9:11 AM