Preventing an Outlook mailitem from entering into a conflict












0















An outlook mailitem is on a network share, and is prone to conflicts especially when modifications are made to it.



The following VBA macro does the following:




  1. Makes changes to a mailitem

  2. Checks if the mailitem is saved and saves it.

  3. Checks the saved mailitem for any conflicts.


How do I modify this code to prevent the mailitem from entering into a conflict in the first place?



Any ideas a welcome.



Sub CheckConflict()
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem

Set olApp = Outlook.Application
Set objMail = olApp.ActiveInspector.CurrentItem

objMail.Subject = "Changing subject and saving mail"
If objMail.Saved = False Then
objMail.Save
End if

If objMail.IsConflict = True Then
Msgbox "Conflict detected!"
End If
Set olApp = Nothing
Set objMail = Nothing
End Sub









share|improve this question



























    0















    An outlook mailitem is on a network share, and is prone to conflicts especially when modifications are made to it.



    The following VBA macro does the following:




    1. Makes changes to a mailitem

    2. Checks if the mailitem is saved and saves it.

    3. Checks the saved mailitem for any conflicts.


    How do I modify this code to prevent the mailitem from entering into a conflict in the first place?



    Any ideas a welcome.



    Sub CheckConflict()
    Dim olApp As Outlook.Application
    Dim objMail As Outlook.MailItem

    Set olApp = Outlook.Application
    Set objMail = olApp.ActiveInspector.CurrentItem

    objMail.Subject = "Changing subject and saving mail"
    If objMail.Saved = False Then
    objMail.Save
    End if

    If objMail.IsConflict = True Then
    Msgbox "Conflict detected!"
    End If
    Set olApp = Nothing
    Set objMail = Nothing
    End Sub









    share|improve this question

























      0












      0








      0








      An outlook mailitem is on a network share, and is prone to conflicts especially when modifications are made to it.



      The following VBA macro does the following:




      1. Makes changes to a mailitem

      2. Checks if the mailitem is saved and saves it.

      3. Checks the saved mailitem for any conflicts.


      How do I modify this code to prevent the mailitem from entering into a conflict in the first place?



      Any ideas a welcome.



      Sub CheckConflict()
      Dim olApp As Outlook.Application
      Dim objMail As Outlook.MailItem

      Set olApp = Outlook.Application
      Set objMail = olApp.ActiveInspector.CurrentItem

      objMail.Subject = "Changing subject and saving mail"
      If objMail.Saved = False Then
      objMail.Save
      End if

      If objMail.IsConflict = True Then
      Msgbox "Conflict detected!"
      End If
      Set olApp = Nothing
      Set objMail = Nothing
      End Sub









      share|improve this question














      An outlook mailitem is on a network share, and is prone to conflicts especially when modifications are made to it.



      The following VBA macro does the following:




      1. Makes changes to a mailitem

      2. Checks if the mailitem is saved and saves it.

      3. Checks the saved mailitem for any conflicts.


      How do I modify this code to prevent the mailitem from entering into a conflict in the first place?



      Any ideas a welcome.



      Sub CheckConflict()
      Dim olApp As Outlook.Application
      Dim objMail As Outlook.MailItem

      Set olApp = Outlook.Application
      Set objMail = olApp.ActiveInspector.CurrentItem

      objMail.Subject = "Changing subject and saving mail"
      If objMail.Saved = False Then
      objMail.Save
      End if

      If objMail.IsConflict = True Then
      Msgbox "Conflict detected!"
      End If
      Set olApp = Nothing
      Set objMail = Nothing
      End Sub






      vba networking outlook save conflict






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 2:16









      BarokBarok

      508




      508
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Minimize the number of times you call Save and do not keep the MailItem object open for any prolonged periods of time.






          share|improve this answer
























          • Dmitry@ How about using a temporary dummy object? objMail_temp = objMail. Make modifications to objMail_temp, then set objMail = objMail_temp, and save objMail (once only) at the end. This way I don't have to worry about crashing objMail since it is not "opened" or "used" at all times. Is this implementable?

            – Barok
            Nov 16 '18 at 6:00













          • That won't make any difference - it won't even know (or care) that you are storing a reference to one of its objects in two variables.

            – Dmitry Streblechenko
            Nov 16 '18 at 14:52











          • Dmitry@ Alright. How about combining the two [if... end if] clauses into one? if objMail.IsConflict = False AND objMail.Saved = False then objmail.Save. Would this detect and prevent a conflict?

            – Barok
            Nov 18 '18 at 5:23













          • Why are you even saving the item? If it is being displayed by Outlook, would it not be the user's prerogative to decide when and if the item needs to be saved?

            – Dmitry Streblechenko
            Nov 18 '18 at 17:34











          • Dimitry@ Wait a minute. Are you saying that objMail.save is not necessary in a network-share? Does the exchange server automatically manage modifications made to the item?

            – Barok
            Nov 19 '18 at 13:47













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330511%2fpreventing-an-outlook-mailitem-from-entering-into-a-conflict%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Minimize the number of times you call Save and do not keep the MailItem object open for any prolonged periods of time.






          share|improve this answer
























          • Dmitry@ How about using a temporary dummy object? objMail_temp = objMail. Make modifications to objMail_temp, then set objMail = objMail_temp, and save objMail (once only) at the end. This way I don't have to worry about crashing objMail since it is not "opened" or "used" at all times. Is this implementable?

            – Barok
            Nov 16 '18 at 6:00













          • That won't make any difference - it won't even know (or care) that you are storing a reference to one of its objects in two variables.

            – Dmitry Streblechenko
            Nov 16 '18 at 14:52











          • Dmitry@ Alright. How about combining the two [if... end if] clauses into one? if objMail.IsConflict = False AND objMail.Saved = False then objmail.Save. Would this detect and prevent a conflict?

            – Barok
            Nov 18 '18 at 5:23













          • Why are you even saving the item? If it is being displayed by Outlook, would it not be the user's prerogative to decide when and if the item needs to be saved?

            – Dmitry Streblechenko
            Nov 18 '18 at 17:34











          • Dimitry@ Wait a minute. Are you saying that objMail.save is not necessary in a network-share? Does the exchange server automatically manage modifications made to the item?

            – Barok
            Nov 19 '18 at 13:47


















          0














          Minimize the number of times you call Save and do not keep the MailItem object open for any prolonged periods of time.






          share|improve this answer
























          • Dmitry@ How about using a temporary dummy object? objMail_temp = objMail. Make modifications to objMail_temp, then set objMail = objMail_temp, and save objMail (once only) at the end. This way I don't have to worry about crashing objMail since it is not "opened" or "used" at all times. Is this implementable?

            – Barok
            Nov 16 '18 at 6:00













          • That won't make any difference - it won't even know (or care) that you are storing a reference to one of its objects in two variables.

            – Dmitry Streblechenko
            Nov 16 '18 at 14:52











          • Dmitry@ Alright. How about combining the two [if... end if] clauses into one? if objMail.IsConflict = False AND objMail.Saved = False then objmail.Save. Would this detect and prevent a conflict?

            – Barok
            Nov 18 '18 at 5:23













          • Why are you even saving the item? If it is being displayed by Outlook, would it not be the user's prerogative to decide when and if the item needs to be saved?

            – Dmitry Streblechenko
            Nov 18 '18 at 17:34











          • Dimitry@ Wait a minute. Are you saying that objMail.save is not necessary in a network-share? Does the exchange server automatically manage modifications made to the item?

            – Barok
            Nov 19 '18 at 13:47
















          0












          0








          0







          Minimize the number of times you call Save and do not keep the MailItem object open for any prolonged periods of time.






          share|improve this answer













          Minimize the number of times you call Save and do not keep the MailItem object open for any prolonged periods of time.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 16 '18 at 2:58









          Dmitry StreblechenkoDmitry Streblechenko

          42.9k32760




          42.9k32760













          • Dmitry@ How about using a temporary dummy object? objMail_temp = objMail. Make modifications to objMail_temp, then set objMail = objMail_temp, and save objMail (once only) at the end. This way I don't have to worry about crashing objMail since it is not "opened" or "used" at all times. Is this implementable?

            – Barok
            Nov 16 '18 at 6:00













          • That won't make any difference - it won't even know (or care) that you are storing a reference to one of its objects in two variables.

            – Dmitry Streblechenko
            Nov 16 '18 at 14:52











          • Dmitry@ Alright. How about combining the two [if... end if] clauses into one? if objMail.IsConflict = False AND objMail.Saved = False then objmail.Save. Would this detect and prevent a conflict?

            – Barok
            Nov 18 '18 at 5:23













          • Why are you even saving the item? If it is being displayed by Outlook, would it not be the user's prerogative to decide when and if the item needs to be saved?

            – Dmitry Streblechenko
            Nov 18 '18 at 17:34











          • Dimitry@ Wait a minute. Are you saying that objMail.save is not necessary in a network-share? Does the exchange server automatically manage modifications made to the item?

            – Barok
            Nov 19 '18 at 13:47





















          • Dmitry@ How about using a temporary dummy object? objMail_temp = objMail. Make modifications to objMail_temp, then set objMail = objMail_temp, and save objMail (once only) at the end. This way I don't have to worry about crashing objMail since it is not "opened" or "used" at all times. Is this implementable?

            – Barok
            Nov 16 '18 at 6:00













          • That won't make any difference - it won't even know (or care) that you are storing a reference to one of its objects in two variables.

            – Dmitry Streblechenko
            Nov 16 '18 at 14:52











          • Dmitry@ Alright. How about combining the two [if... end if] clauses into one? if objMail.IsConflict = False AND objMail.Saved = False then objmail.Save. Would this detect and prevent a conflict?

            – Barok
            Nov 18 '18 at 5:23













          • Why are you even saving the item? If it is being displayed by Outlook, would it not be the user's prerogative to decide when and if the item needs to be saved?

            – Dmitry Streblechenko
            Nov 18 '18 at 17:34











          • Dimitry@ Wait a minute. Are you saying that objMail.save is not necessary in a network-share? Does the exchange server automatically manage modifications made to the item?

            – Barok
            Nov 19 '18 at 13:47



















          Dmitry@ How about using a temporary dummy object? objMail_temp = objMail. Make modifications to objMail_temp, then set objMail = objMail_temp, and save objMail (once only) at the end. This way I don't have to worry about crashing objMail since it is not "opened" or "used" at all times. Is this implementable?

          – Barok
          Nov 16 '18 at 6:00







          Dmitry@ How about using a temporary dummy object? objMail_temp = objMail. Make modifications to objMail_temp, then set objMail = objMail_temp, and save objMail (once only) at the end. This way I don't have to worry about crashing objMail since it is not "opened" or "used" at all times. Is this implementable?

          – Barok
          Nov 16 '18 at 6:00















          That won't make any difference - it won't even know (or care) that you are storing a reference to one of its objects in two variables.

          – Dmitry Streblechenko
          Nov 16 '18 at 14:52





          That won't make any difference - it won't even know (or care) that you are storing a reference to one of its objects in two variables.

          – Dmitry Streblechenko
          Nov 16 '18 at 14:52













          Dmitry@ Alright. How about combining the two [if... end if] clauses into one? if objMail.IsConflict = False AND objMail.Saved = False then objmail.Save. Would this detect and prevent a conflict?

          – Barok
          Nov 18 '18 at 5:23







          Dmitry@ Alright. How about combining the two [if... end if] clauses into one? if objMail.IsConflict = False AND objMail.Saved = False then objmail.Save. Would this detect and prevent a conflict?

          – Barok
          Nov 18 '18 at 5:23















          Why are you even saving the item? If it is being displayed by Outlook, would it not be the user's prerogative to decide when and if the item needs to be saved?

          – Dmitry Streblechenko
          Nov 18 '18 at 17:34





          Why are you even saving the item? If it is being displayed by Outlook, would it not be the user's prerogative to decide when and if the item needs to be saved?

          – Dmitry Streblechenko
          Nov 18 '18 at 17:34













          Dimitry@ Wait a minute. Are you saying that objMail.save is not necessary in a network-share? Does the exchange server automatically manage modifications made to the item?

          – Barok
          Nov 19 '18 at 13:47







          Dimitry@ Wait a minute. Are you saying that objMail.save is not necessary in a network-share? Does the exchange server automatically manage modifications made to the item?

          – Barok
          Nov 19 '18 at 13:47




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330511%2fpreventing-an-outlook-mailitem-from-entering-into-a-conflict%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Academy of Television Arts & Sciences

          L'Équipe

          1995 France bombings