Emailing from ASP.NET using Office 365 Online Exchange
Trying to send email from asp.net application.
Emailing to server address: Smtp.office365.com
Port - 587
Connection Security - STARTTLS
I have SMTP user name and SMTP password.
Fails to send email.
The code uses the SmtpClient, as follows:
String userName = "name@example.com";
String password = "Password";
MailAddress RecipientEmail = new MailAddress(EmailTo);
MailAddress SenderEmail = new MailAddress(cEmailFrom);
MailMessage msg = new MailMessage(SenderEmail, RecipientEmail);
msg.Subject = "Test";
msg.Body = "This is a test";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.office365.com:587");
client.Credentials = new System.Net.NetworkCredential(userName, password);
client.EnableSsl = true;
client.Send(msg);
The error message: Failure sending email. No other information.
But if I specify the port:
client.port = 587
instead of adding it to the host name, I get a very long error:
Transaction failed. The server response was: 5.2.0
STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:BC110000, 17.43559:0000000094000000000000000100000000000000, 20.52176:140FBF85130010100A00D231, 20.50032:140FBF85831710100A00E231, 0.35180:86260000, 255.23226:0A00C931, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 16.55847:DC000000, 17.43559:0000000088010000000000001E00000000000000, 20.52176:140FBF85130010109F260000, 20.50032:140FBF8583171010A4260000, 0.35180:0A00D330, 255.23226:A9260000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:B3260000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:0A007530, 0.37692:02010480, 0.44092:00000000, 0.40348:02010480, 0.34608:04000100, 0.55056:00000000, 0.42768:302E3134, 0.56112:31393A44, 0.52807:30363031, 4.33016:DC040000, 7.40748:010000000000010B2D343438, 7.57132:000000000000000037323032,
What is missing?
asp.net email smtpclient
add a comment |
Trying to send email from asp.net application.
Emailing to server address: Smtp.office365.com
Port - 587
Connection Security - STARTTLS
I have SMTP user name and SMTP password.
Fails to send email.
The code uses the SmtpClient, as follows:
String userName = "name@example.com";
String password = "Password";
MailAddress RecipientEmail = new MailAddress(EmailTo);
MailAddress SenderEmail = new MailAddress(cEmailFrom);
MailMessage msg = new MailMessage(SenderEmail, RecipientEmail);
msg.Subject = "Test";
msg.Body = "This is a test";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.office365.com:587");
client.Credentials = new System.Net.NetworkCredential(userName, password);
client.EnableSsl = true;
client.Send(msg);
The error message: Failure sending email. No other information.
But if I specify the port:
client.port = 587
instead of adding it to the host name, I get a very long error:
Transaction failed. The server response was: 5.2.0
STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:BC110000, 17.43559:0000000094000000000000000100000000000000, 20.52176:140FBF85130010100A00D231, 20.50032:140FBF85831710100A00E231, 0.35180:86260000, 255.23226:0A00C931, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 16.55847:DC000000, 17.43559:0000000088010000000000001E00000000000000, 20.52176:140FBF85130010109F260000, 20.50032:140FBF8583171010A4260000, 0.35180:0A00D330, 255.23226:A9260000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:B3260000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:0A007530, 0.37692:02010480, 0.44092:00000000, 0.40348:02010480, 0.34608:04000100, 0.55056:00000000, 0.42768:302E3134, 0.56112:31393A44, 0.52807:30363031, 4.33016:DC040000, 7.40748:010000000000010B2D343438, 7.57132:000000000000000037323032,
What is missing?
asp.net email smtpclient
That's not even close to all of the code. How do you build the message? How do you set the credentials? And what error do you get when you run this?
– Joel Coehoorn
Dec 28 '18 at 23:53
@JoelCoehoorn I have been trying to update my initial post but the browser (IE 11) keeps hanging. Sorry.
– Hidalgo
Dec 29 '18 at 0:07
@JoelCoehoorn I edited my initial post.
– Hidalgo
Dec 29 '18 at 1:32
add a comment |
Trying to send email from asp.net application.
Emailing to server address: Smtp.office365.com
Port - 587
Connection Security - STARTTLS
I have SMTP user name and SMTP password.
Fails to send email.
The code uses the SmtpClient, as follows:
String userName = "name@example.com";
String password = "Password";
MailAddress RecipientEmail = new MailAddress(EmailTo);
MailAddress SenderEmail = new MailAddress(cEmailFrom);
MailMessage msg = new MailMessage(SenderEmail, RecipientEmail);
msg.Subject = "Test";
msg.Body = "This is a test";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.office365.com:587");
client.Credentials = new System.Net.NetworkCredential(userName, password);
client.EnableSsl = true;
client.Send(msg);
The error message: Failure sending email. No other information.
But if I specify the port:
client.port = 587
instead of adding it to the host name, I get a very long error:
Transaction failed. The server response was: 5.2.0
STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:BC110000, 17.43559:0000000094000000000000000100000000000000, 20.52176:140FBF85130010100A00D231, 20.50032:140FBF85831710100A00E231, 0.35180:86260000, 255.23226:0A00C931, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 16.55847:DC000000, 17.43559:0000000088010000000000001E00000000000000, 20.52176:140FBF85130010109F260000, 20.50032:140FBF8583171010A4260000, 0.35180:0A00D330, 255.23226:A9260000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:B3260000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:0A007530, 0.37692:02010480, 0.44092:00000000, 0.40348:02010480, 0.34608:04000100, 0.55056:00000000, 0.42768:302E3134, 0.56112:31393A44, 0.52807:30363031, 4.33016:DC040000, 7.40748:010000000000010B2D343438, 7.57132:000000000000000037323032,
What is missing?
asp.net email smtpclient
Trying to send email from asp.net application.
Emailing to server address: Smtp.office365.com
Port - 587
Connection Security - STARTTLS
I have SMTP user name and SMTP password.
Fails to send email.
The code uses the SmtpClient, as follows:
String userName = "name@example.com";
String password = "Password";
MailAddress RecipientEmail = new MailAddress(EmailTo);
MailAddress SenderEmail = new MailAddress(cEmailFrom);
MailMessage msg = new MailMessage(SenderEmail, RecipientEmail);
msg.Subject = "Test";
msg.Body = "This is a test";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.office365.com:587");
client.Credentials = new System.Net.NetworkCredential(userName, password);
client.EnableSsl = true;
client.Send(msg);
The error message: Failure sending email. No other information.
But if I specify the port:
client.port = 587
instead of adding it to the host name, I get a very long error:
Transaction failed. The server response was: 5.2.0
STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:BC110000, 17.43559:0000000094000000000000000100000000000000, 20.52176:140FBF85130010100A00D231, 20.50032:140FBF85831710100A00E231, 0.35180:86260000, 255.23226:0A00C931, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 16.55847:DC000000, 17.43559:0000000088010000000000001E00000000000000, 20.52176:140FBF85130010109F260000, 20.50032:140FBF8583171010A4260000, 0.35180:0A00D330, 255.23226:A9260000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:B3260000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:0A007530, 0.37692:02010480, 0.44092:00000000, 0.40348:02010480, 0.34608:04000100, 0.55056:00000000, 0.42768:302E3134, 0.56112:31393A44, 0.52807:30363031, 4.33016:DC040000, 7.40748:010000000000010B2D343438, 7.57132:000000000000000037323032,
What is missing?
asp.net email smtpclient
asp.net email smtpclient
edited Dec 29 '18 at 3:18
Joel Coehoorn
307k95490721
307k95490721
asked Dec 28 '18 at 23:45
HidalgoHidalgo
4171826
4171826
That's not even close to all of the code. How do you build the message? How do you set the credentials? And what error do you get when you run this?
– Joel Coehoorn
Dec 28 '18 at 23:53
@JoelCoehoorn I have been trying to update my initial post but the browser (IE 11) keeps hanging. Sorry.
– Hidalgo
Dec 29 '18 at 0:07
@JoelCoehoorn I edited my initial post.
– Hidalgo
Dec 29 '18 at 1:32
add a comment |
That's not even close to all of the code. How do you build the message? How do you set the credentials? And what error do you get when you run this?
– Joel Coehoorn
Dec 28 '18 at 23:53
@JoelCoehoorn I have been trying to update my initial post but the browser (IE 11) keeps hanging. Sorry.
– Hidalgo
Dec 29 '18 at 0:07
@JoelCoehoorn I edited my initial post.
– Hidalgo
Dec 29 '18 at 1:32
That's not even close to all of the code. How do you build the message? How do you set the credentials? And what error do you get when you run this?
– Joel Coehoorn
Dec 28 '18 at 23:53
That's not even close to all of the code. How do you build the message? How do you set the credentials? And what error do you get when you run this?
– Joel Coehoorn
Dec 28 '18 at 23:53
@JoelCoehoorn I have been trying to update my initial post but the browser (IE 11) keeps hanging. Sorry.
– Hidalgo
Dec 29 '18 at 0:07
@JoelCoehoorn I have been trying to update my initial post but the browser (IE 11) keeps hanging. Sorry.
– Hidalgo
Dec 29 '18 at 0:07
@JoelCoehoorn I edited my initial post.
– Hidalgo
Dec 29 '18 at 1:32
@JoelCoehoorn I edited my initial post.
– Hidalgo
Dec 29 '18 at 1:32
add a comment |
1 Answer
1
active
oldest
votes
The important part from the error is the phrase "SendAsDenied
".
Office 365 won't let you use your account on their smtp servers to send e-mail messages from someone else's address. You just can't do it. If you need to do that, you need to manage your own smtp server... and let me tell, that's a whole other can of worms, requiring an ability to understand and configure some or all of rDNS, SPF, DKIM, Domain-Keys, and DMARC.
Thank you very much. I understand and agree with your suggestion. But what bothers me is why when I specify the port with the host name (e.g. "Smtp.office365.com:587") I get no detailed error. But when I remove the port # from the Smtp.office365.com and specify it as client.port = 587, I get a very different and long error message. Does it make sense to you?
– Hidalgo
Dec 29 '18 at 14:13
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53965488%2femailing-from-asp-net-using-office-365-online-exchange%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The important part from the error is the phrase "SendAsDenied
".
Office 365 won't let you use your account on their smtp servers to send e-mail messages from someone else's address. You just can't do it. If you need to do that, you need to manage your own smtp server... and let me tell, that's a whole other can of worms, requiring an ability to understand and configure some or all of rDNS, SPF, DKIM, Domain-Keys, and DMARC.
Thank you very much. I understand and agree with your suggestion. But what bothers me is why when I specify the port with the host name (e.g. "Smtp.office365.com:587") I get no detailed error. But when I remove the port # from the Smtp.office365.com and specify it as client.port = 587, I get a very different and long error message. Does it make sense to you?
– Hidalgo
Dec 29 '18 at 14:13
add a comment |
The important part from the error is the phrase "SendAsDenied
".
Office 365 won't let you use your account on their smtp servers to send e-mail messages from someone else's address. You just can't do it. If you need to do that, you need to manage your own smtp server... and let me tell, that's a whole other can of worms, requiring an ability to understand and configure some or all of rDNS, SPF, DKIM, Domain-Keys, and DMARC.
Thank you very much. I understand and agree with your suggestion. But what bothers me is why when I specify the port with the host name (e.g. "Smtp.office365.com:587") I get no detailed error. But when I remove the port # from the Smtp.office365.com and specify it as client.port = 587, I get a very different and long error message. Does it make sense to you?
– Hidalgo
Dec 29 '18 at 14:13
add a comment |
The important part from the error is the phrase "SendAsDenied
".
Office 365 won't let you use your account on their smtp servers to send e-mail messages from someone else's address. You just can't do it. If you need to do that, you need to manage your own smtp server... and let me tell, that's a whole other can of worms, requiring an ability to understand and configure some or all of rDNS, SPF, DKIM, Domain-Keys, and DMARC.
The important part from the error is the phrase "SendAsDenied
".
Office 365 won't let you use your account on their smtp servers to send e-mail messages from someone else's address. You just can't do it. If you need to do that, you need to manage your own smtp server... and let me tell, that's a whole other can of worms, requiring an ability to understand and configure some or all of rDNS, SPF, DKIM, Domain-Keys, and DMARC.
answered Dec 29 '18 at 3:22
Joel CoehoornJoel Coehoorn
307k95490721
307k95490721
Thank you very much. I understand and agree with your suggestion. But what bothers me is why when I specify the port with the host name (e.g. "Smtp.office365.com:587") I get no detailed error. But when I remove the port # from the Smtp.office365.com and specify it as client.port = 587, I get a very different and long error message. Does it make sense to you?
– Hidalgo
Dec 29 '18 at 14:13
add a comment |
Thank you very much. I understand and agree with your suggestion. But what bothers me is why when I specify the port with the host name (e.g. "Smtp.office365.com:587") I get no detailed error. But when I remove the port # from the Smtp.office365.com and specify it as client.port = 587, I get a very different and long error message. Does it make sense to you?
– Hidalgo
Dec 29 '18 at 14:13
Thank you very much. I understand and agree with your suggestion. But what bothers me is why when I specify the port with the host name (e.g. "Smtp.office365.com:587") I get no detailed error. But when I remove the port # from the Smtp.office365.com and specify it as client.port = 587, I get a very different and long error message. Does it make sense to you?
– Hidalgo
Dec 29 '18 at 14:13
Thank you very much. I understand and agree with your suggestion. But what bothers me is why when I specify the port with the host name (e.g. "Smtp.office365.com:587") I get no detailed error. But when I remove the port # from the Smtp.office365.com and specify it as client.port = 587, I get a very different and long error message. Does it make sense to you?
– Hidalgo
Dec 29 '18 at 14:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53965488%2femailing-from-asp-net-using-office-365-online-exchange%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
That's not even close to all of the code. How do you build the message? How do you set the credentials? And what error do you get when you run this?
– Joel Coehoorn
Dec 28 '18 at 23:53
@JoelCoehoorn I have been trying to update my initial post but the browser (IE 11) keeps hanging. Sorry.
– Hidalgo
Dec 29 '18 at 0:07
@JoelCoehoorn I edited my initial post.
– Hidalgo
Dec 29 '18 at 1:32