Guten Morgen liebe Grommunio-Community,
Ich versuche die EWS Schnittstelle zu benutzen um damit in C# eine E-Mail zu senden.
Falls relevant: ich verwende diese Bibliothek Exchange Web Services
Prinzipiell war ich erfolgreich. Ich konnte eine Mail senden.
Dabei wird der <m:CreateItem MessageDisposition="SendOnly"> befehl benutzt, ich bekomme eine Response mit response Code "NoError". Alles perfekt soweit ich das überblicken kann.
Hier die Requests:
<Trace Tag="EwsRequestHttpHeaders" Tid="1" Time="2025-05-13 05:44:38Z">
POST /EWS/Exchange.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept: text/xml
User-Agent: ExchangeServicesClient/15.00.0913.015
Accept-Encoding: gzip,deflate
</Trace>
<Trace Tag="EwsRequest" Tid="1" Time="2025-05-13 05:44:38Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body>
<m:CreateItem MessageDisposition="SendOnly">
<m:Items>
<t:Message>
<t:ItemClass>IPM.Note</t:ItemClass>
<t:Subject>Test Mail</t:Subject>
<t:Body BodyType="HTML">Testbody</t:Body>
<t:ToRecipients>
<t:Mailbox>
<t:Name>email@example.de</t:Name>
<t:EmailAddress>email@example.de</t:EmailAddress>
</t:Mailbox>
</t:ToRecipients>
</t:Message>
</m:Items>
</m:CreateItem>
</soap:Body>
</soap:Envelope>
</Trace>
<Trace Tag="EwsResponseHttpHeaders" Tid="1" Time="2025-05-13 05:44:39Z">
HTTP/1.1 200 OK
Connection: keep-alive
Content-Security-Policy: default-src 'self' data:; frame-src * blob:; connect-src * data: blob:; font-src * data:; img-src * data: blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; object-src 'self'; base-uri 'self'; frame-ancestors 'self';
Permissions-Policy: accelerometer=(), autoplay=(self), camera=(self), display-capture=(self), encrypted-media=(self), fullscreen=(self), geolocation=(self), gyroscope=(), keyboard-map=(self), magnetometer=(), microphone=(self), midi=(), payment=(), picture-in-picture=(self), publickey-credentials-get=(self), screen-wake-lock=(self), sync-xhr=(), usb=(), web-share=(self), xr-spatial-tracking=(self)
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block
Referrer-Policy: no-referrer
Content-Type: text/xml
Content-Length: 825
</Trace>
<Trace Tag="EwsResponse" Tid="1" Time="2025-05-13 05:44:39Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP:Header>
<t:ServerVersionInfo xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" MajorVersion="15" MinorVersion="0" MajorBuildNumber="847" MinorBuildNumber="4040" Version="V2017_07_11" />
</SOAP:Header>
<SOAP:Body>
<m:CreateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:CreateItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items />
</m:CreateItemResponseMessage>
</m:ResponseMessages>
</m:CreateItemResponse>
</SOAP:Body>
</SOAP:Envelope>
</Trace>
Nun wollte ich eine E-Mail mit Attachment hinzufügen. Hierbei ist so wie ich das EWS Protkoll verstanden habe das vorgehen aber etwas anders. Microsoft EWS
Das geht dann nicht mit nur einem Befehl sondern in drei Schritten:
Verwenden des EmailMessage-Objekts zum Erstellen einer E-Mail-Nachricht.
Verwenden der Methoden AttachmentCollection.AddFileAttachment und AttachmentCollection.AddItemAttachment zum Hinzufügen von Anlagen zur Nachricht.
Verwenden sie die EmailMessage.SendAndSaveCopy-Methode , um die Nachricht an die Empfänger zu senden und die Nachricht im Ordner Gesendete Elemente zu speichern.
Beim ausführen dieser Requests erhalte ich allerdings beim <m:CreateAttachment> request die Antwort "Unknown request 'CreateAttachment'."
Requests:
<Trace Tag="EwsRequestHttpHeaders" Tid="1" Time="2025-05-13 05:48:50Z">
POST /EWS/Exchange.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept: text/xml
User-Agent: ExchangeServicesClient/15.00.0913.015
Accept-Encoding: gzip,deflate
</Trace>
<Trace Tag="EwsRequest" Tid="1" Time="2025-05-13 05:48:50Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body>
<m:CreateItem MessageDisposition="SaveOnly">
<m:Items>
<t:Message>
<t:ItemClass>IPM.Note</t:ItemClass>
<t:Subject>Test Mail</t:Subject>
<t:Body BodyType="HTML">Testbody</t:Body>
<t:Attachments>
<t:FileAttachment>
<t:Name>testfile.txt</t:Name>
<t:IsInline>false</t:IsInline>
<t:IsContactPhoto>false</t:IsContactPhoto>
<t:Content>dGVzdA==</t:Content>
</t:FileAttachment>
</t:Attachments>
<t:ToRecipients>
<t:Mailbox>
<t:Name>mail@example.de</t:Name>
<t:EmailAddress>mail@example.de</t:EmailAddress>
</t:Mailbox>
</t:ToRecipients>
</t:Message>
</m:Items>
</m:CreateItem>
</soap:Body>
</soap:Envelope>
</Trace>
<Trace Tag="EwsResponseHttpHeaders" Tid="1" Time="2025-05-13 05:48:51Z">
HTTP/1.1 200 OK
Connection: keep-alive
Content-Security-Policy: default-src 'self' data:; frame-src * blob:; connect-src * data: blob:; font-src * data:; img-src * data: blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; object-src 'self'; base-uri 'self'; frame-ancestors 'self';
Permissions-Policy: accelerometer=(), autoplay=(self), camera=(self), display-capture=(self), encrypted-media=(self), fullscreen=(self), geolocation=(self), gyroscope=(), keyboard-map=(self), magnetometer=(), microphone=(self), midi=(), payment=(), picture-in-picture=(self), publickey-credentials-get=(self), screen-wake-lock=(self), sync-xhr=(), usb=(), web-share=(self), xr-spatial-tracking=(self)
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block
Referrer-Policy: no-referrer
Content-Type: text/xml
Content-Length: 1071
</Trace>
<Trace Tag="EwsResponse" Tid="1" Time="2025-05-13 05:48:51Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP:Header>
<t:ServerVersionInfo xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" MajorVersion="15" MinorVersion="0" MajorBuildNumber="847" MinorBuildNumber="4040" Version="V2017_07_11" />
</SOAP:Header>
<SOAP:Body>
<m:CreateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:CreateItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId Id="AAAAAPQ6OL0ZCsZPuAb1QV6D7oEHAAwAAAClGHtvvNzqHtA8VlcAAAAAAAwAAAwAAAClGHtvvNzqHtA8VlcAAAAFAB4AAAM=" ChangeKey="DAAAAKUYe2+83Ooe0DxWV4AAACISCQ==" />
<t:Flag>
<t:FlagStatus>NotFlagged</t:FlagStatus>
</t:Flag>
</t:Message>
</m:Items>
</m:CreateItemResponseMessage>
</m:ResponseMessages>
</m:CreateItemResponse>
</SOAP:Body>
</SOAP:Envelope>
</Trace>
<Trace Tag="EwsRequestHttpHeaders" Tid="1" Time="2025-05-13 05:48:51Z">
POST /EWS/Exchange.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept: text/xml
User-Agent: ExchangeServicesClient/15.00.0913.015
Accept-Encoding: gzip,deflate
</Trace>
<Trace Tag="EwsRequest" Tid="1" Time="2025-05-13 05:48:51Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body>
<m:CreateAttachment>
<m😛arentItemId Id="AAAAAPQ6OL0ZCsZPuAb1QV6D7oEHAAwAAAClGHtvvNzqHtA8VlcAAAAAAAwAAAwAAAClGHtvvNzqHtA8VlcAAAAFAB4AAAM=" />
<m:Attachments>
<t:FileAttachment>
<t:Name>testfile.txt</t:Name>
<t:IsInline>false</t:IsInline>
<t:IsContactPhoto>false</t:IsContactPhoto>
<t:Content>dGVzdA==</t:Content>
</t:FileAttachment>
</m:Attachments>
</m:CreateAttachment>
</soap:Body>
</soap:Envelope>
</Trace>
<Trace Tag="EwsResponseHttpHeaders" Tid="1" Time="2025-05-13 05:48:51Z">
HTTP/1.1 500 Internal Server Error
Connection: keep-alive
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: none
Referrer-Policy: no-referrer
Content-Type: text/xml
Content-Length: 328
</Trace>
<Trace Tag="EwsResponse" Tid="1" Time="2025-05-13 05:48:51Z" Version="15.00.0913.015">
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<SOAP:Body>
<SOAP:Fault>
<faultcode xsi:type="xsd:string">SOAP:Server</faultcode>
<faultstring xsi:type="xsd:string">Unknown request 'CreateAttachment'.</faultstring>
</SOAP:Fault>
</SOAP:Body>
</SOAP:Envelope>
</Trace>
Ich habe mal ins Gromox repo geschaut und dort diesen Request auch nicht gefunden.
Meine Frage: Gehe ich richtig in der Annahme, dass Grommunio über EWS aktuell einfach keine Mails mit Anhang versenden kann, da die Methode "CreateAttachment" nicht implementiert ist?
Allerdings habe ich gesehen, dass erfolgreich Evolution über EWS verbunden werden kann Evolution und Grommunio und ich mir nicht vorstellen kann, dass Anhänge nicht funktionieren.
Vielleicht seht ihr ja sofort, was ich falsch mache. Oder habt Ideen wo ich noch weiter suchen kann.
Danke für eure Hilfe,
Patrick