Ik ben nog niet zo bekend met het mailen vanuit visual studio. Ik heb het onderstaande stukje code
Op mijn PC heb ik Visual Studio 2005 staan, en zou graag deze mailing willen testen. Ik heb nog geen hosting ergens. Zit er bij Visual Studio standaard een SMTP server of is er een gratis uitbreiding of iets?
Op mijn PC heb ik Visual Studio 2005 staan, en zou graag deze mailing willen testen. Ik heb nog geen hosting ergens. Zit er bij Visual Studio standaard een SMTP server of is er een gratis uitbreiding of iets?
code:
1
2
3
4
5
6
7
| <system.net>
<mailSettings>
<smtp from="test@foo.com">
<network host="smtp.localhost" port="25" userName="username" password="secret" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net> |
C#:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| MailMessage message = new MailMessage(); message.From = new MailAddress("sender@foo.bar.com"); message.To.Add(new MailAddress("recipient1@foo.bar.com")); message.To.Add(new MailAddress("recipient2@foo.bar.com")); message.To.Add(new MailAddress("recipient3@foo.bar.com")); message.CC.Add(new MailAddress("carboncopy@foo.bar.com")); message.Subject = "This is my subject"; message.Body = "<html><body><b>Hello World</b>" + " <font color=\"red\">ASP.NET</font></body></html>"; SmtpClient client = new SmtpClient(); client.Send(message); Response.Write("Email was queued to disk"); |