1

Is it possible to send an e-mail with attachment in Office 365? As attachment we would want the attachment from a list item or local system or a document from a document library.

I tried using a SMTP server in a custom webpart (which failed because SMTP isn't allowed)

Is this solution possible?

I had written below code for send by mail.

$(document).on('click',"button[data-automation-id='sendByEmailDialogSendButton']", function (event) {
    loadScript("https://smtpjs.com/v3/smtp.js", function(){
        debugger;
        Email.send({
            SecureToken: "35c2dcb7-b282-47ce-b894-4fe52a3f071a",
            Host : "smtp.gmail.com",
            port:"587",
            EnableSsl :false,
            Username : "Gmail Username",
            Password : "password",
            To : 'SharePOint Id([email protected])',
            From : "Gmail Id([email protected])",
            Subject : "Send by admin",
            Body : "And this is the body"}).then( message => alert(message));
    });

Throwing error “The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required.”

1 Answer 1

0

To send email from SharePoint, using JavaScript, then you can use SP.Utilities.EmailProperties object (sp.js), it has the following properties,

From, To, CC, BCC, Subject, Body , 

it doesn't have any property for attachments

As an alternate, you can upload the document into a library and send the link over emails.

For more information, refer the below links,

https://www.c-sharpcorner.com/article/send-email-with-attachment-in-office-365-sharepoint-online/

https://stackoverflow.com/questions/27377376/how-do-i-send-email-with-inline-attachments

For complete code to send email from SharePoint without attachment, refer this link

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.