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

Support sending Calendar event with API #188

Open
morki opened this issue Jul 3, 2024 · 5 comments
Open

Support sending Calendar event with API #188

morki opened this issue Jul 3, 2024 · 5 comments

Comments

@morki
Copy link

morki commented Jul 3, 2024

In our application, we need to send calendar events together with our emails. For now we are using Simple Java Mail to compose our messages and send with SMTP.

We would like to use Mox Web API to send those directly, but in API documentation there is no field for calendar part.

Here is nice structure compositor to see how to integrate calendar part into multipart message: https://www.simplejavamail.org/rfc-compliant.html#section-explore-multipart

I would like to propose addition to API:

type Message struct {
    //...
    ICalendar string
}

or maybe more generaly some AlternativeParts array with content type and body.

@mjl-
Copy link
Owner

mjl- commented Jul 8, 2024

Hi @morki! You should be able to add files to outgoing messages with the webapi. Either inline or as attachments. See the "Send" method, https://pkg.go.dev/github.com/mjl-/[email protected]/webapi#Client.Send. The SendRequest has fields InlineFiles and AttachedFiles, see https://pkg.go.dev/github.com/mjl-/[email protected]/webapi#SendRequest. Instead of including the file data in the JSON request, you can also make a multipart/form-data request with form field(s) "inlinefile" and/or "attachedfile". The Client.Send docs have a curl example to make such a request.

I hope that's enough to make the webapi an option. If this isn't working or convenient, I'm interested in learning what the blocker is.

I'm not sure it's a good idea to add a field for this specific type of attachment. I can see how this is useful for this use case, but other use cases will likely follow. Also, I'm still working on calendaring support in mox. When that is ready, a higher-level API for composing + enqueuing messages with calendar events but be more helpful. I'm thinking about something like adding a "CalendarEvent" field to a SendRequest where you add a JSON object with start/end/title/location/etc fields, and an ICS file is composed and added to the message.

@morki
Copy link
Author

morki commented Jul 8, 2024

Thank you very much for your response. I know about attachment support, but I think it is not the same. I will try to explain. When you attach files, it constructs different mime cascade as seen in this link:

https://www.simplejavamail.org/rfc-compliant.html#section-explore-multipart

image

But what I was looking for is this:

image

Where iCalendar event is just alternative part on the same level as HTML and plain text.

I think the future addition of CalendarEvent with specific fields, constructing the ICS automatically is super cool and will solve this, when it will be ready.

I look forward to calendaring/contact support in mox, it will be huge :)

@mjl-
Copy link
Owner

mjl- commented Jul 19, 2024

Thanks for the explanation, that makes sense. What if we add a new field AlternativeFiles []File, similar to the existing InlineFiles and AttachedFiles? Then you can add an ICS file as alternative, and other types of alternatives can be added too, e.g. a pdf/xml/json/richtext version of the message/data.

@morki
Copy link
Author

morki commented Jul 19, 2024

Yeah, it will be awesome and more generic :)

mjl- added a commit that referenced this issue Aug 23, 2024
…e Send method

with new field "AlternativeFiles" in the JSON body, or with "alternativefile" form file uploads.

can be used if there is a (full) alternative representation (alternative to
text and/or html part), like a calendar item, or PDF file.

for issue #188 by morki
@mjl-
Copy link
Owner

mjl- commented Aug 23, 2024

@morki The commit just now adds the AlternativeFiles field to the request body of the Send method. A form file field "alternativefile" will work as well. Similar to inline & attached files.
See https://www.xmox.nl/b/#6c488ead0b9ea8e11e5aff28b706121ee36d9401 for a binary with this commit, in case you want to give it a try.

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