SOLVED

Send an email from SPFx client-side webpart without exchange online

Copper Contributor

Hello All,

 

We're trying to build an spfx client-side webpart which should send a confirmation email to the user logged in (CC'in a mailbox) on a button click. I have tried Graph Api and pnp.js, and they both work great on my personal tenant where exchange online is enabled. But on our company prod tenant we do not have exchange online enabled. 

 

Any idea if GraphApi/PnP.js has a dependency on enabling exchange online to send email. 

 

Thank you all ! 

 

 

8 Replies
best response confirmed by jnr-O365 (Copper Contributor)

SharePoint API doesn't allow posts to external emails.

Thanks, @Juan Carlos González Martín. As @imv1826 mentioned API is not allowing to posts to external emails. 

@jnr-O365 

I am trying to use the GraphAPI for sending mail through SPFX : SendAs. But things are not working for me. PFB the code example. Could you please post a sample of what you have implemented.

I have verified the 'SendAs' permission in EAC as well.

The error that I am getting clearly depicts that it is a permission issue, but I am not able to figure out .

"The user account which was used to submit this request does not have the right to send mail on behalf of the specified sending account".

 

My code :

Mail Message : 

from:
{
emailAddress: { address: "shared-mailbox@domain.com" }
}
 
My Graph client : 
const graphClient: MSGraphClient = await this.props.context.msGraphClientFactory.getClient();
await graphClient
.api(`users/admin@domain.com/sendMail`)
 
 
Any guidance will be highly appreciated !

@pallavisharma Have you granted permissions to the account in Exchange Online to allow the Send As permission from the user?

@pallavisharma: I think you can only send email to a valid SharePointOnline user when you're using mail end point in Graph. You may not be able to send emails to outlook mailbox.
1 best response

Accepted Solutions