Mail with File Attachments don't work - attachments content doesn't get serialized.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
- Ambito
- api
Direzione di ricerca
Inizia da packages/msgraph-sdk/models/index.ts e ispeziona serializeFileAttachment, in particolare il modo in cui isSerializingDerivedType influisce su contentBytes. Esegui la riproduzione TypeScript fornita per l'invio di posta con la versione 1.0.0-preview.64 dell'SDK. Il lavoro è completo quando contentBytes dell'allegato viene serializzato e il messaggio viene inviato correttamente senza l'errore relativo alla proprietà mancante.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
I am trying to send a Mail with an Image-Attachment via the Graph SDK. This is what my Test-Code looks like:
import { ClientSecretCredential } from "@azure/identity";
import { AzureIdentityAuthenticationProvider } from "@microsoft/kiota-authentication-azure";
import {
createGraphServiceClient,
GraphRequestAdapter,
} from "@microsoft/msgraph-sdk";
import { SendMailPostRequestBody } from "@microsoft/msgraph-sdk-users/users/item/sendMail/index.js";
import "@microsoft/msgraph-sdk-users";
import { FileAttachment } from "@microsoft/msgraph-sdk/models/index.js";
import fs from "fs";
const fromRecipient = "<from@mail.com>";
const toRecipient = "<to@mail.com>";
const credential = new ClientSecretCredential(
<tenantId>,
<clientId>,
<clientSecret>
);
// @microsoft/kiota-authentication-azure
const authProvider = new AzureIdentityAuthenticationProvider(credential, [
"https://graph.microsoft.com/.default",
]);
const requestAdapter = new GraphRequestAdapter(authProvider);
const client = createGraphServiceClient(requestAdapter);
const fileBuffer = fs.readFileSync("test.jpeg");
const fileAttachment: FileAttachment = {
odataType: "#microsoft.graph.fileAttachment",
name: "test.jpg",
contentType: "image/jpeg",
contentBytes: fileBuffer,
size: fileBuffer.byteLength,
};
const body: SendMailPostRequestBody = {
message: {
subject: "Testmail",
body: {
content:
'<style type="text/css">html, p { font-size:14px !important; font-family: Arial, Helvetica, sans-serif !important; }</style><p>this is a test message</p>',
contentType: "html",
},
hasAttachments: true,
toRecipients: [
{
emailAddress: {
address: toRecipient,
},
},
],
attachments: [fileAttachment],
},
};
try {
const user = client.users.byUserId(fromRecipient);
const mail = user.sendMail;
await mail.post(body);
console.log("done");
} catch (error) {
console.log(error.message);
}
My dependencies are:
"dependencies": {
"@azure/identity": "^4.10.2",
"@microsoft/kiota-authentication-azure": "^1.0.0-preview.96",
"@microsoft/kiota-http-fetchlibrary": "^1.0.0-preview.96",
"@microsoft/msgraph-sdk": "^1.0.0-preview.64",
"@microsoft/msgraph-sdk-users": "^1.0.0-preview.64",
...
},
When I send this, I get an error with this message: 'Required property is missing.'
I debugged it and saw, that in https://github.com/microsoftgraph/msgraph-sdk-typescript/blob/main/packages/msgraph-sdk/models/index.ts the serializeFileAttachment Function only gets called with isSerializingDerivedType = true which leads to the state where "contentBytes" never gets written.
When i change isSerializingDerivedType to false in debug mode, the mail with the attachments got sent successfully!
Can you please fix that?
Thank you.
Expected behavior
The attachment's "contentBytes" gets written.
How to reproduce
Send a Mail with a File Attachment via Graph SDK - as shown above.
SDK Version
1.0.0-preview.64
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```Required property is missing.
</details>
### Configuration
_No response_
### Other information
_No response_
- Lingua principale
- TypeScript
- Stelle
- 44
- Fork
- 7
- Merge medio
- 12h 40m
- PR unite (30g)
- 5
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoftgraph/msgraph-sdk-typescript
-
Can't add users to groups ApertaToTriage type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
microsoftgraph/msgraph-sdk-typescript#917 · 6 commenti ·
-
TypeScript 6.x.x bump Apertastatus:waiting-for-triage ToTriage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
microsoftgraph/msgraph-sdk-typescript#974 · 1 commento ·
-
status:waiting-for-triage ToTriage type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
microsoftgraph/msgraph-sdk-typescript#953 · 1 commento · 1 reazione ·
-
status:waiting-for-triage ToTriage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
microsoftgraph/msgraph-sdk-typescript#912 · 1 commento ·
-
status:waiting-for-triage ToTriage type:feature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
Tutte le issue di microsoftgraph/msgraph-sdk-typescript
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
copse-dev/agent-pane#2953 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
[Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity Apertabug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
calcite-components needs triage refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Esri/calcite-design-system#15203 ·