MCPcopy Index your code
hub / github.com/sendgrid/sendgrid-nodejs / setAttachments

Method setAttachments

packages/helpers/classes/mail.js:377–393  ·  view source on GitHub ↗

* Set attachments

(attachments)

Source from the content-addressed store, hash-verified

375 * Set attachments
376 */
377 setAttachments(attachments) {
378 if (this._doArrayCheck('attachments', attachments)) {
379 if (!attachments.every(attachment => typeof attachment.content === 'string')) {
380 throw new Error('Expected each attachment to contain a `content` string');
381 }
382 if (!attachments.every(attachment => typeof attachment.filename === 'string')) {
383 throw new Error('Expected each attachment to contain a `filename` string');
384 }
385 if (!attachments.every(attachment => !attachment.type || typeof attachment.type === 'string')) {
386 throw new Error('Expected the attachment\'s `type` field to be a string');
387 }
388 if (!attachments.every(attachment => !attachment.disposition || typeof attachment.disposition === 'string')) {
389 throw new Error('Expected the attachment\'s `disposition` field to be a string');
390 }
391 this.attachments = attachments;
392 }
393 }
394
395 /**
396 * Add attachment

Callers 1

fromDataMethod · 0.95

Calls 1

_doArrayCheckMethod · 0.95

Tested by

no test coverage detected