Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot sendMail with attachments #26

Open
ConradIrwin opened this issue Jul 31, 2020 · 1 comment
Open

Cannot sendMail with attachments #26

ConradIrwin opened this issue Jul 31, 2020 · 1 comment

Comments

@ConradIrwin
Copy link

Currently the way that SendMail is defined, it is not obvious how to send a message with attachments.

Message is defined with Attachments: []Attachment; but when you pass an Attachment object to the API, you must provide either a FileAttachment or an ItemAttachment. In my case I wanted to provide a FileAttachment, which requires setting the ContentBytes field, which is not present on the Attachment struct.

I realize this is somewhat of a problem with representing the graph data-types (which make use of subclassing) in Go (which doesn't); and wondered if you'd given this some thought already – it's definitely not clear what the right solution is. Maybe an AddFileAttachment(file *FileAttachment) method on SendMailRequestBuilder?

@blaskovicz
Copy link

I hit this problem, except in the reverse order. When I am attempting to read the content of an attachment for a message, I'm seeing contentBytes in the underlying interface via dump(attachment) but there is no ContentBytes field on said struct.

@ConradIrwin after messing around I finally realized that the Object struct has an AdditionalData map[string]interface{} that contains all the extra fields not present in the leaf structs. For example, I was able to access attachedFile.AdditionalData["contentBytes"] to read - perhaps you can use it for write as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants