none
Outlook Appointment Flashes Open RRS feed

  • Question

  • Hi,

    When I create an outlook appointment item it opens and and then closes the appointment window on my screen quickly and it very annoying.

    How do I stop this from happening.

    Ive tried placing the thread.IsBackground = True; and apptItem.Display(False);

    -------------------

    • Changed type Harry Zhu Friday, November 14, 2008 11:12 AM no response
    • Changed type Harry Zhu Friday, November 14, 2008 11:12 AM no response
    • Changed type Causton Monday, November 17, 2008 6:50 AM im back
    • Changed type Causton Monday, November 17, 2008 6:50 AM im back
    • Changed type Causton Monday, November 17, 2008 6:51 AM Im back
    Saturday, November 8, 2008 10:02 AM

Answers

  • Hi,

    Just comment the sentence :    apptItem.Display(false);
    the windows do not show up any more.

    Best regards,
    Harry
    • Proposed as answer by Harry Zhu Tuesday, November 18, 2008 7:18 AM
    • Marked as answer by Causton Tuesday, November 18, 2008 8:56 AM
    Tuesday, November 18, 2008 7:17 AM

All replies

  • Hi,

    Could you be more specific ? What do you mean the appointment window?Could you post the actual code you're working with? Without it, we're just guessing.

    The following link gives a good sample of creating outlook appointment:
    http://www.outlookcode.com/codedetail.aspx?id=775

    When you try the code , add it:
    using Outlook = Microsoft.Office.Interop.Outlook;
    It works well here.

    Best regards,
    Harry
    • Proposed as answer by Harry Zhu Wednesday, November 12, 2008 5:26 AM
    • Unproposed as answer by Harry Zhu Thursday, November 13, 2008 1:37 AM
    Wednesday, November 12, 2008 5:26 AM
  •  

    We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

    Thank you!

    Friday, November 14, 2008 11:11 AM
  • Sorry for the delay.

    Here is the code.

    ThreadStart operation = new ThreadStart(d1.OlJobEntryAppointment);
    Thread theThread = new Thread(operation);
    theThread.Name = d1.Name.ToString();
    theThread.IsBackground =
    true;
    theThread.Start();

    public void
    OlJobEntryAppointment()
    {
        Outlook.
    _NameSpace olNS = Globals.ThisAddIn.Application.GetNamespace("MAPI"
    );
        Outlook.
    MAPIFolder
    olDF = 
            olNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.
    OlDefaultFolders
    .olFolderCalendar);
        Outlook.
    MAPIFolder olMF = olDF.Folders.GetFirst();

    foreach (Job olaj in Jobs) // olaj = Outlook Appointment Job
    {
        if (olaj != null) {int myHour = 0, myMinute = 0;
        if (olaj.jobDescription.Contains("Bill Prep")) { myHour = 10; }
        else if (olaj.jobDescription.Contains("Move")) { myHour = 13; }
        else { myHour = 10; myMinute = 30; }
        int year = Name.Year;
        int month = Name.Month;
        int day = Name.Day;
        int hour = myHour;
        int minute = myMinute;

        DateTime jobTime = new DateTime(year, month, day, hour, minute, 0);
        TimeSpan duration = new TimeSpan(1, 0, 0, 0);

        Outlook._AppointmentItem apptItem = 
            (Outlook.
    _AppointmentItem)olMF.Items.Add("IPM.Appointment"); 

        apptItem.Display(
    false);
        apptItem.Subject = olaj.jobDescription.ToString();
        apptItem.Start = jobTime;
        if (olaj.jobDescription.Contains("Bill Prep")){ apptItem.End = jobTime.Add(duration); }
        apptItem.Save();
        apptItem.Close(Microsoft.Office.Interop.Outlook.
    OlInspectorClose.olDiscard);
        }
    }
    }

    The problem is the actual appointment window opening and then closing for each job I create from my array of jobs. I tried to correct it with the highlighted code but its not working for me.

    Monday, November 17, 2008 6:49 AM
  • Hi,

    If you want to keep the appointment window opening ,you can comment the following sentence:
     apptItem.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olDiscard);

    Best regards,
    Harry
    Tuesday, November 18, 2008 2:13 AM
  • Hi,

    I actually dont want it to display on the screen. It flashed open between this two lines of code.

    Outlook._AppointmentItem apptItem = 
            (Outlook.
    _AppointmentItem)olMF.Items.Add("IPM.Appointment"); 

        apptItem.Display(
    false);

    I need some way of suppressing it. I thought putting into a thread and saying it is a background thread would work but it didnt.

    Regards,
    Tuesday, November 18, 2008 4:25 AM
  • Hi,

    Just comment the sentence :    apptItem.Display(false);
    the windows do not show up any more.

    Best regards,
    Harry
    • Proposed as answer by Harry Zhu Tuesday, November 18, 2008 7:18 AM
    • Marked as answer by Causton Tuesday, November 18, 2008 8:56 AM
    Tuesday, November 18, 2008 7:17 AM
  • this has worked wonderfully. Thankyou. It doesnt make sense but it works :-)
    Tuesday, November 18, 2008 8:56 AM