1

just wondering how we can trigger MS Outlook new mail from client side, using ReactJs. The email should have some content (a table and some texts) in it, also with an attachment (PDF file) downloaded from server side. All the email content can be retrieved from state property 'this.state.data' (it's an array of objects).

Right now I have something below (an html way). When user clicks a button, It can open up new mail screen with subject and SentTo specified. How can I do the rest (content + attachment)?

<button type="button" className="btn btn-default"><a href="mailto:[email protected]?subject=Test">Send Out Email</a></button>

For attachment, I need to (probably) write a get method to download from server first. Then how can we attach it to email?

I already know how to download it from server and display it on another tab (it works fine):

  handleDownload = (path) => {
    window.open(
        "/myController/GetFileFromServer?filePath=" + path,
        "_blank"
    );

Alternatively, I can also send email via server side, it feels easier for me. However, users likely need to enrich the email manually first before sending. Hence I thought client side would be more suitable for my case.

1

1 Answer 1

1

As per this answer it is not possible to specify attachments with a mailto:

However, as per this answer you can add email content along with subject line

I'd suggest you show a text area for user to enter in email content and then send an email from the server

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Varinder! Yea I also found that post which says attachment is not possible with mailTo. Probably I have to drop that idea. For the email content, I do have to let users to review/enrich before sending, and it's really a case by case situation and a generic textarea may not help. Also, the email which I need to send is quite 'colourful', with a proper table, paragraphs, highlighting, bold, underline etc.., adding the content along with subject line seems difficult to me.
I see, handling this on the server side may be less challenging

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.