---
title: "Skicka mail via formulär"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/178860-skicka-mail-via-formulär"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "J07"
published: "2009-06-04T16:32:19.000Z"
updated: "2009-06-06T08:17:20.000Z"
replies: 3
views: 647
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/178860-skicka-mail-via-formulär"
---

# Skicka mail via formulär

## #1 — J07, 2009-06-04T16:32Z

Har letat efter kod som skickar iväg från detta enkla formulär med Asp.net men får inget att funka. Någon som kan enkel kod för detta? Samt hur ska koden vara, i samma fil eller en seperat bakgrunds fil för kod?

```
<body>
<form id="form1" name="form1" method="post" action="">
  <p>Namn: 
    <input type="text" name="namn" id="namn" />
</p>
  <p>Övrigt: 
    <input type="text" name="Ovrigt" id="Ovrigt" />
</p>
  <p>
    <input type="submit" name="skicka" id="skicka" value="Skicka" />
  </p>
</form>
</body>
</html>
```

Permalänk: https://www.webforum.nu/p/178860

## #2 — Sjodahl, 2009-06-04T19:06Z

Kanske kan detta vara något: <http://www.aspheute.com/english/20000918.asp>

WebForm1.aspx

```
<body>
    <form id="form1" runat="server">
    <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
    <asp:TextBox ID="txtFrom" runat="server"></asp:TextBox>
    <asp:TextBox ID="txtSubject" runat="server"></asp:TextBox>
    <asp:Button ID="btnSend" runat="server" Text="Skicka" onclick="btnSend_Click" />
    </form>
</body>
```

WebForm1.aspx.cs

```
using System.Web.Mail;

namespace Test
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
            string strTo = txtEmail.Text;
            string strFrom = txtFrom.Text;
            string strSubject = txtSubject.Text;

            SmtpMail.Send(strFrom, strTo, strSubject,"some body text..");
        }
    }
}
```

OBS, inte testad kod.

Permalänk: https://www.webforum.nu/p/2189665

## #3 — ize, 2009-06-06T07:28Z

System.Web.Mail är på väg ut... nu gäller System.Net.Mail

Här hittar du allt du behöver för att skicka mejl ifrån .NET

<http://www.systemnetmail.com/>

Permalänk: https://www.webforum.nu/p/2189803

## #4 — johaseo, 2009-06-06T08:17Z

Testad kod: 

```
Dim mail As New MailMessage()

'set the addresses
mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("you@yourcompany.com")

'set the content
mail.Subject = "This is an email"
 mail.Body = "this is a sample body with html in it. <b>This is bold</b> <font color=#336699>This is blue</font>"
mail.IsBodyHtml = True

'send the message
Dim smtp As New SmtpClient("127.0.0.1")
smtp.Send(mail)
```

Permalänk: https://www.webforum.nu/p/2189805

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/178860-skicka-mail-via-formulär
