React Native
React Native
Send Email with hotmail.com, live.com, or outlook.com
See more SMTP Examples
Send email using your Microsoft hotmail.com, live.com, or outlook.com account via the smtp.office365.com SMTP server.See the Guide for Creating an Application to Send Email from Hotmail.com, Live.com, or Outlook.com
Chilkat React Native Downloads
import { Email, JsonObject, MailMan } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const mailman = new MailMan();
mailman.smtpHost = 'smtp.office365.com';
mailman.smtpPort = 587;
mailman.startTLS = true;
// This could be your hotmail.com, live.com, or outlook.com account.
mailman.smtpUsername = 'yourName@live.com';
// Load the previously saved OAuth2 access token.
const json = new JsonObject();
try {
json.loadFile('qa_data/tokens/hotmail.json');
} catch {
console.log(json.lastErrorText);
return;
}
mailman.oAuth2AccessToken = json.stringOf('access_token');
const email = new Email();
// Note: If you send an email such as this, it can easily go to your Junk or Trash email folders.
email.subject = 'This is a test';
email.body = 'This is a test';
// This could be your hotmail.com, live.com, or outlook.com account.
email.from = 'My Hotmail Account <yourName@live.com>';
email.addTo('Joe Example', 'joe@example.com');
try {
await mailman.openSmtpConnectionAsync();
} catch {
console.log(mailman.lastErrorText);
console.log(`ConnectFailReason = ${mailman.connectFailReason}`);
return;
}
try {
await mailman.smtpAuthenticateAsync();
} catch {
console.log(mailman.lastErrorText);
return;
}
try {
await mailman.sendEmailAsync(email);
} catch {
console.log(mailman.lastErrorText);
return;
}
await mailman.closeSmtpConnectionAsync();
console.log('Email Sent.');
}