SOLVED
Home

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

%3CLINGO-SUB%20id%3D%22lingo-sub-394848%22%20slang%3D%22en-US%22%3ESend%20an%20email%20from%20SPFx%20client-side%20webpart%20without%20exchange%20online%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-394848%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe're%20trying%20to%20build%20an%20spfx%20client-side%20webpart%20which%20should%20send%20a%20confirmation%20email%20to%20the%20user%20logged%20in%20(CC'in%20a%20mailbox)%20on%20a%20button%20click.%20I%20have%20tried%20Graph%20Api%20and%20pnp.js%2C%20and%20they%20both%20work%20great%20on%20my%20personal%20tenant%20where%20exchange%20online%20is%20enabled.%20But%20on%20our%20company%20prod%20tenant%20we%20do%20not%20have%20exchange%20online%20enabled.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20idea%20if%20GraphApi%2FPnP.js%20has%20a%20dependency%20on%20enabling%20exchange%20online%20to%20send%20email.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20all%20!%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-394848%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Egraph%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESend%20by%20Email%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-401295%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20an%20email%20from%20SPFx%20client-side%20webpart%20without%20exchange%20online%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-401295%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Fdelucagiuliano.com%2Finviting-external-user-with-sharepoint-framework%2F%23.XKj3qFUzbIU%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdelucagiuliano.com%2Finviting-external-user-with-sharepoint-framework%2F%23.XKj3qFUzbIU%3C%2FA%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-400986%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20an%20email%20from%20SPFx%20client-side%20webpart%20without%20exchange%20online%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-400986%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F60%22%20target%3D%22_blank%22%3E%40Juan%20Carlos%20Gonz%C3%A1lez%20Mart%C3%ADn%3C%2FA%3E.%20As%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F314903%22%20target%3D%22_blank%22%3E%40imv1826%3C%2FA%3E%26nbsp%3Bmentioned%26nbsp%3B%3CSPAN%3EAPI%20is%20not%20allowing%20to%20posts%20to%20external%20emails.%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-400841%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20an%20email%20from%20SPFx%20client-side%20webpart%20without%20exchange%20online%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-400841%22%20slang%3D%22en-US%22%3E%3CP%3ESharePoint%20API%20doesn't%20allow%20posts%20to%20external%20emails.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-396744%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20an%20email%20from%20SPFx%20client-side%20webpart%20without%20exchange%20online%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-396744%22%20slang%3D%22en-US%22%3EWhy%20not%20use%20SPO%20REST%20API%3F%20%3CA%20href%3D%22https%3A%2F%2Fgist.github.com%2FBasantPandey%2F05189832546f2c6cc0bd008fcfec3264%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgist.github.com%2FBasantPandey%2F05189832546f2c6cc0bd008fcfec3264%3C%2FA%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-677507%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20an%20email%20from%20SPFx%20client-side%20webpart%20without%20exchange%20online%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-677507%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F314409%22%20target%3D%22_blank%22%3E%40jnr-O365%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20use%20the%20GraphAPI%20for%20sending%20mail%20through%20SPFX%20%3A%20SendAs.%20But%20things%20are%20not%20working%20for%20me.%20PFB%20the%20code%20example.%20Could%20you%20please%20post%20a%20sample%20of%20what%20you%20have%20implemented.%3C%2FP%3E%3CP%3EI%20have%20verified%20the%20'SendAs'%20permission%20in%20EAC%20as%20well.%3C%2FP%3E%3CP%3EThe%20error%20that%20I%20am%20getting%20clearly%20depicts%20that%20it%20is%20a%20permission%20issue%2C%20but%20I%20am%20not%20able%20to%20figure%20out%20.%3C%2FP%3E%3CP%3E%22The%20user%20account%20which%20was%20used%20to%20submit%20this%20request%20does%20not%20have%20the%20right%20to%20send%20mail%20on%20behalf%20of%20the%20specified%20sending%20account%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20code%20%3A%3C%2FP%3E%3CP%3EMail%20Message%20%3A%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3Efrom%3A%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EemailAddress%3A%20%7B%3C%2FSPAN%3E%3CSPAN%3E%20address%3A%20%22shared-mailbox%40domain.com%22%3C%2FSPAN%3E%3CSPAN%3E%20%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EMy%20Graph%20client%20%3A%26nbsp%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3Econst%3C%2FSPAN%3E%20%3CSPAN%3EgraphClient%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%3CSPAN%3E%20MSGraphClient%20%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3Eawait%3C%2FSPAN%3E%20%3CSPAN%3Ethis%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Eprops%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Econtext%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EmsGraphClientFactory%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EgetClient%3C%2FSPAN%3E%3CSPAN%3E()%3C%2FSPAN%3E%3CSPAN%3E%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Eawait%3C%2FSPAN%3E%20%3CSPAN%3EgraphClient%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E.api(%60users%2Fadmin%40domain.com%2FsendMail%60)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EAny%20guidance%20will%20be%20highly%20appreciated%20!%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-677537%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20an%20email%20from%20SPFx%20client-side%20webpart%20without%20exchange%20online%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-677537%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F356497%22%20target%3D%22_blank%22%3E%40pallavisharma%3C%2FA%3E%26nbsp%3BHave%20you%20granted%20permissions%20to%20the%20account%20in%20Exchange%20Online%20to%20allow%20the%20Send%20As%20permission%20from%20the%20user%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
jnr-O365
Occasional 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 ! 

 

 

6 Replies

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?

Related Conversations