Search code examples
xamarinmvvmcross

MVVMCross add image as attachment using Email Plugin


I'm using MVVMCross Email Plugin. Is there any way to attach an image to email message?

Mvx.Resolve<IMvxComposeEmailTask>().ComposeEmail(to, String.Empty, subject, body, false);

Solution

  • You can use IMvxComposeEmailTaskEx instead of IMvxComposeEmailTask. It provides method with attachments param:

    void ComposeEmail(
        IEnumerable<string> to, 
        IEnumerable<string> cc = null, 
        string subject = null, 
        string body = null, 
        bool isHtml = false, 
        IEnumerable<EmailAttachment> attachments = null, 
        string dialogTitle = null
    );
    


    UPD:

    What ContentType I must set?

    Chose your content type from this list of mime-types. E.g. image/jpeg for jpeg images or image/png for png.