2009-12-23 22 views
5

Sto provando a creare un appuntamento nel calendario di Microsoft Outlook (2003) di un'altra persona che utilizza il codice sottostante. Mentre eseguo questo programma, The Appointment viene salvato nel mio calendario. Ma non viene inviato al destinatario.Come posso creare e inviare appuntamenti al calendario di Microsoft Outlook?

try 
{ 
    Microsoft.Office.Interop.Outlook.Application app = null; 
    Microsoft.Office.Interop.Outlook.AppointmentItem appt = null; 

    app = new Microsoft.Office.Interop.Outlook.Application(); 

    appt = (Microsoft.Office.Interop.Outlook.AppointmentItem)app 
     .CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem); 
    appt.Subject = "Meeting "; 
    appt.Body = "Test Appointment body"; 
    appt.Location = "TBD"; 
    appt.Start = Convert.ToDateTime("12/23/2009 05:00:00 PM"); 
    appt.Recipients.Add("[email protected]"); 
    appt.End = Convert.ToDateTime("12/23/2009 6:00:00 PM"); 
    appt.ReminderSet = true; 
    appt.ReminderMinutesBeforeStart = 15; 
    appt.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; 
    appt.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy; 
    appt.Save(); 
    appt.Send(); 
} 
catch (COMException ex) 
{ 
    Response.Write(ex.ToString()); 
} 

Mi manca qualcosa? Qualcuno può aiutarmi a risolvere questo problema?

risposta

3

Prova ad aggiungere:

appt.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting; 

stato di default è un appuntamento che non sono sicuro che viene inviato.

5

Dopo aver ottenuto l'appuntamento:

Outlook.MailItem mailItem = appt.ForwardAsVcal(); 
mailItem.To = "recipient's email address"; 
mailItem.Send(); 
1

Ecco come ho risolto questo problema:

ho messo (come il post di Sonny Boy):

Ma ho anche dovuto creare un file web.config e impostare l'accesso di autorizzazione per evitare qualsiasi COMException:

<system.web> 
    <authorization> 
    <deny users="?"/> 
    </authorization> 
</system.web> 
Problemi correlati