2017-06-28 7 views
0

I Anwendung bin zu entwickeln, die EWS-API-Termine in Outlook Empfänger senden verwaltet verwendet, Nun gibt es Bedarf Anhänge Termin hinzuzufügen, ich bin in der Lage, Anhänge von E-Mails anhängen, aber wenn ich gleiche Technik wie Artikel Anhänge Anbringen zu mailen, aber Anhänge sind nicht anhängig, mein Code wie untenWie Dateianhänge Termin mit EWS hinzufügen?

 public string sendCalanderEvntAsReply(EntityLayer.Data_Contracts.AppointmentDTO appointment) 
     { 

       Appointment app = new Appointment(service); 
       app.Subject = appointment.Subject; 
       app.Body = appointment.Body; 
       app.Start = Convert.ToDateTime(appointment.Start); 
       app.End = Convert.ToDateTime(appointment.End); 
       app.Location = appointment.Location; 

       foreach (string obj in appointment.Attendees) 
       { 
        app.RequiredAttendees.Add(obj); 
       } 

       if (appointment.Attachments != null && 
        appointment.Attachments.Count > 0) 
       { 
        foreach (var att in appointment.Attachments) 
        { 
         app.Attachments.AddFileAttachment(att.FileName); 
        } 
       } 

       app.Save(SendInvitationsMode.SendToAllAndSaveCopy);  
} 

gibt es irgendein Problem in meinem Code? bitte helfen.

dank

Antwort

3

Mit EWS, wenn Sie Sie eine Anlage mit der Meeting-Einladung senden möchten, müssen zunächst den Termin speichern, bevor Sie die Nachricht sonst senden Sie nur die Anlage erhalten auf die Besitzer so mit Ihrem Code kopieren Sie verwenden sollte Danke so etwas wie

  Appointment app = new Appointment(service); 
      app.Subject = appointment.Subject; 
      app.Body = appointment.Body; 
      app.Start = Convert.ToDateTime(appointment.Start); 
      app.End = Convert.ToDateTime(appointment.End); 
      app.Location = appointment.Location; 



      if (appointment.Attachments != null && 
       appointment.Attachments.Count > 0) 
      { 
       foreach (var att in appointment.Attachments) 
       { 
        app.Attachments.AddFileAttachment(att.FileName); 
       } 
      } 
      app.Save(SendInvitationsMode.SendToNone); 

      foreach (string obj in appointment.Attendees) 
      { 
       app.RequiredAttendees.Add(obj); 
      } 

      app.Update(ConflictResolutionMode.AutoResolve, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy); 
+0

@Glen es funktioniert .. – Roshan

+0

ich ein ähnliches Problem habe, wenn Anhänge zu entfernen und neue hinzufügen. Aber diese Lösung hat nicht für mich funktioniert. Hier ist mein Fall wahrscheinlich, wenn u einen Blick haben könnte: https://stackoverflow.com/questions/48658409/how-to-update-delete-file-attachments-to-appointment-using-ews –

Verwandte Themen