Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Email API's #27

Closed
mattleibow opened this issue Feb 25, 2018 · 13 comments
Closed

Email API's #27

mattleibow opened this issue Feb 25, 2018 · 13 comments
Assignees
Labels
in-progress Actively being worked on.
Milestone

Comments

@mattleibow
Copy link
Contributor

mattleibow commented Feb 25, 2018

A simple API to send an email.

static class Email {
    static bool IsAttachmentSupported { get; }
    static bool IsHtmlMessageSupported { get; }

    // should throw a NotSupportedOnDeviceException if the device is not capable.
    Task ComposeAsync(EmailMessage message);
class EmailMessage {
    EmailMessage(string subject, string body, params string[] to);

    string Subject { get; set }
    string Body { get; set }
    bool IsMessageHtml { get; set }
    IList<string> To  { get; set; }
    IList<string> Bcc { get; set; }
    IList<string> Cc { get; set; }
    IList<EmailAttachment> Attachments { get; set; }

    // should throw a NotSupportedOnDeviceException if the device is not capable.
    void Attach(string attachmentName, string contentType, Stream stream);
    // should throw a NotSupportedOnDeviceException if the device is not capable.
    void Attach(string attachmentName, string contentType, string filename);
    // should throw a NotSupportedOnDeviceException if the device is not capable.
    void Attach(string attachmentName, string contentType, byte[] data);
}
class EmailAttachment {
    string Name { get; set; }
    string ContentType { get; set; }
    string FileName { get; set; }
    Stream Stream { get; set; }
}

For the discussion around exceptions, see #19

@Redth Redth mentioned this issue Feb 25, 2018
@mattleibow
Copy link
Contributor Author

We should check to see if platforms can support streams or data chunks. We could throw, or we could save to a temporary file.

@mattleibow mattleibow added this to the Preview-1 milestone Feb 25, 2018
@Redth
Copy link
Member

Redth commented Feb 25, 2018

I believe they all support streams, and if they support streams, you can MemoryStream a byte[]. I don't think this will be an issue.

I'm still not quite happy with EmailAttachment... I think we should try and get rid of FileName, at least as a public property.

@jamesmontemagno
Copy link
Collaborator

I would also say I am pretty cool with Attachments not making v1 :)

@Redth Redth added this to New in Triage Mar 7, 2018
@Redth Redth added this to Ready in v0.5.0-preview Mar 7, 2018
@jamesmontemagno jamesmontemagno added the up-for-grabs Implementation from community can be started. label Mar 8, 2018
@alanag13
Copy link

alanag13 commented Mar 8, 2018

should this include a method to open the constructed email in the device's default client (similar to if the user had clicked a mailto link)?

@Redth
Copy link
Member

Redth commented Mar 12, 2018

Updated the original issue with a bit different of API. EmailMessage is now a separate class with all of the options for sending an email. Email is now a static class to send messages and check capabilities.

@Redth
Copy link
Member

Redth commented Mar 12, 2018

@alanag13 what are device capabilities like here? Do all the platforms generally support both sending an email without user intervention as well as 'opening' the email up on their device to send?

@alanag13
Copy link

@Redth I assumed sending was supported on all relevant devices since that's what this spec seems to imply. I know that "open" is supported on both iOS and Android because I have done this. On UWP I haven't personally done this but I feel like I've used applications where I had this experience. I'd have to look at little closer for that platform in particular.

@alanag13
Copy link

@alanag13
Copy link

alanag13 commented Mar 12, 2018

@Redth actually, unless I'm missing something, some quick googling suggests that on most of these platforms sending an email programmatically without user intervention on the default client isn't possible with the API unless you authenticate to an SMTP server and such... so i'm thinking SendAsync should be LaunchMailClientAsync or something

@Redth
Copy link
Member

Redth commented Mar 12, 2018

Yep, I think the confusion here is that Send in this case is really Compose. I've updated the original issue to be ComposeAsync which all the current target platforms seem to support.

@Redth Redth removed the up-for-grabs Implementation from community can be started. label Mar 12, 2018
@Redth
Copy link
Member

Redth commented Mar 12, 2018

We've got someone internally working on this. PR will be up shortly with progress.

This was referenced Mar 15, 2018
@Redth Redth moved this from Ready for Implementation to In Progress in v0.5.0-preview Mar 27, 2018
@Redth Redth removed this from New in Triage Mar 27, 2018
@mattleibow mattleibow self-assigned this Mar 29, 2018
@jamesmontemagno jamesmontemagno added in-progress Actively being worked on. and removed enhancement labels Mar 29, 2018
Redth pushed a commit that referenced this issue Apr 4, 2018
* email API initial commit
UWP OK

* Email Sample and Device Tests

* API according to comments

* Android Composing finished

* Update the Email API

* Update the tests - removed the emil tests as this will leave the current app

* Update the tests - removed the emil tests as this will leave the current app

* Add base for email attachments

* Removing attachments as this is not as simple as one might expect...

* Removing usless email tests

* Return fast

* Update Email.uwp.cs

* Added the empty email docs

* Warnings instead of messages for missing docs as this is serious

* This should be private

* Updated existing docs to match their APIs

* Added the email docs

* Updated the samples description

* Fix test email address
@Redth Redth moved this from In Progress to Done in v0.5.0-preview Apr 6, 2018
@mattleibow mattleibow moved this from Done to Closed in v0.5.0-preview Apr 26, 2018
@ephraimf
Copy link

How can I use Email.ComposeAsync to send an attachment?

@mattleibow
Copy link
Contributor Author

@ephraimf This is tracked here: #130 and here: #416

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in-progress Actively being worked on.
Projects
No open projects
v0.5.0-preview
  
Closed
Development

No branches or pull requests

6 participants