SOLVED
Home

Send an email from SPFx client-side webpart

%3CLINGO-SUB%20id%3D%22lingo-sub-176021%22%20slang%3D%22en-US%22%3ESend%20an%20email%20from%20SPFx%20client-side%20webpart%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-176021%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Community%20Members%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20am%20trying%20to%20create%20an%20SPFx%20client-side%20webpart%20which%20would%20be%20used%20to%20send%20an%20email%20from%20the%20logged%20in%20user%20account.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20have%20been%20testing%20the%20%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fzh-tw%2Fgraph%2Fdocs%2Fapi-reference%2Fbeta%2Fapi%2Fuser_sendmail%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Egraph%20api%20send%20mail%20method%3C%2FA%3E%26nbsp%3Bbut%20in%20any%20case%20I%20receive%20%3CEM%3E403%20Unauthorized%20error%3C%2FEM%3E.%20On%20the%20other%20hand%2C%20I%20am%20able%20to%20%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Fgraph%2Fdocs%2Fapi-reference%2Fv1.0%2Fapi%2Fuser_get%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Eget%20user%20information%20using%20the%20graph%20api%20method%3C%2FA%3E%20or%20even%20I%20am%20able%20to%20create%20an%20appointment%20on%20the%20user%20calendar%2C%20based%20on%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2Fsp-dev-fx-extensions%2Ftree%2Fmaster%2Fsamples%2Freact-command-discuss-now%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EDiscuss%20Now%20SPFx%20extension%20sample%3C%2FA%3E%20published%20on%20the%20samples%20repository.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20do%20not%20want%20to%20use%20any%20other%20tools%2C%20like%20Flow%2C%20that%20it%20is%20used%20in%20this%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FTBag%2FSPFxFlowEmailWebPart%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Esample%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EAny%20ideas%20on%20what%20could%20I%20do%20to%20send%20an%20email%20from%20an%20SPFx%20client-side%20webpart%3F%3C%2FP%3E%0A%3CP%3EThank%20you%20all%20in%20advance!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-176565%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20an%20email%20from%20SPFx%20client-side%20webpart%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-176565%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20very%20much%20Juan%20Carlos%20and%26nbsp%3B%3CSPAN%3EVishwanatha!%20I've%20tried%20to%20use%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-JS-Core%2Fwiki%2FWorking-With%3A-SP.Utilities.Utility%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EPnP-JS-Core%3C%2FA%3E%26nbsp%3Band%20it%20works%20perfectly!!!%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-176342%22%20slang%3D%22en-US%22%3ERE%3A%20Send%20an%20email%20from%20SPFx%20client-side%20webpart%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-176342%22%20slang%3D%22en-US%22%3EHow%20about%20pnp.js%20send%20email%20option%3F%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-JS-Core%2Fwiki%2FWorking-With%3A-SP.Utilities.Utility%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-JS-Core%2Fwiki%2FWorking-With%3A-SP.Utilities.Utility%3C%2FA%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-176083%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20an%20email%20from%20SPFx%20client-side%20webpart%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-176083%22%20slang%3D%22en-US%22%3EWhat%20about%20using%20SPO%20REST%20API%3F%20%3CA%20href%3D%22http%3A%2F%2Fwww.enjoysharepoint.com%2FArticles%2FDetails%2Fhow-to-send-email-from-sharepoint-online-using-rest-api-21621.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.enjoysharepoint.com%2FArticles%2FDetails%2Fhow-to-send-email-from-sharepoint-online-using-rest-api-21621.aspx%3C%2FA%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi Community Members,

 

I am trying to create an SPFx client-side webpart which would be used to send an email from the logged in user account. 

I have been testing the graph api send mail method but in any case I receive 403 Unauthorized error. On the other hand, I am able to get user information using the graph api method or even I am able to create an appointment on the user calendar, based on the Discuss Now SPFx extension sample published on the samples repository. 

I do not want to use any other tools, like Flow, that it is used in this sample.

Any ideas on what could I do to send an email from an SPFx client-side webpart?

Thank you all in advance!

3 Replies
Highlighted
Highlighted

Thank you very much Juan Carlos and Vishwanatha! I've tried to use PnP-JS-Core and it works perfectly!!!