Best way to send an email from a .NET application?

后端 未结 6 1933
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 07:16

I\'m working on a Windows Forms (.NET 3.5) application that has a built-in exception handler to catch any (heaven forbid) exceptions that may arise. I\'d like the exception

6条回答
  •  隐瞒了意图╮
    2020-12-06 08:10

    In a controlled environment, using SmtpClient would be the answer. But on a user's machine you would need an SMTP server to send through.

    You could prompt the user for their SMTP credentials, but I think that would be impractical for your case. As a user, I would not want to provide my SMTP credentials to a random app (think SPAM). You also don't want to hard-code your own SMTP credentials into the app, it would be trivial for a malicious user to sniff those credentials and use your server to send SPAM.

    Ideally you would be able to use the user's mail agent to send the email. I was thinking you might be able to formulate and execute a mailto: URL, but I'm not sure if you'd be able to specify the body or any attachments for the message.

提交回复
热议问题