So I have a database program, MVC4, C#, published to Azure.

An agent will create records in the database, and then clients will view them. Records can only be created or edited by an agent.

What I'm having trouble with is the mail function. I'd like to have a function so that when the agent clicks save, whether after editing or creating, an email is sent to the client, referencing the record. The email will include a record locator. The client email and the record locator are items in each record. 

I got the form up, but I'm having trouble with the controller and the System.Main.Net . My Edit controller code is below.

```
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TrepPortal.Models;
using System.Net.Mail;

    //
    // GET: /AgntActions/Edit/5

    public ActionResult Edit(int id = 0)
    {
        ClientActions clientactions = db.ClientActions.Find(id);
        if (clientactions == null)
        {
            return HttpNotFound();
        }
        return View(clientactions);
    }

    //
    // POST: /AgntActions/Edit/5

    [HttpPost]
    public ActionResult Edit(ClientActions clientactions)
    {
        if (ModelState.IsValid)
        {
            db.Entry(clientactions).State = EntityState.Modified;
            db.SaveChanges();

            //mail function
            MailMessage message = new MailMessage();
            message.From = new MailAddress("nick@cooktravel.net");
            //message.To.Add(new MailAddress("nick@cooktravel.net"));
            message.To.Add(clientactions.ClientEmail);
            message.Subject = "This is my subject";
            message.Body = "Your Cook Travel reservation has been updated. The record locator is "clientactions.SabreLocator" . Please visit cooktravelportal.net to view it.";

            //SmtpClient client = new SmtpClient("smtp.cooktravel.net, 495");//old
            SmtpClient client = new SmtpClient("smtp.cooktravel.net", 25);//

            client.UseDefaultCredentials = false;
            client.EnableSsl = false;
            client.Credentials = new System.Net.NetworkCredential("nick@cooktravel.net", "Password");
            client.DeliveryMethod = SmtpDeliveryMethod.Network;

            client.Send(message); //on debug, error comes here as SmtpException unhandled

            return RedirectToAction("Index");
        }
        return View(clientactions);
    }

```

Now I don't have a whole lot of experience. I put this together by reading many articles and examples. Also, if I'm missing any using statements, let me know. Any feedback is appreciated. Thanks!

27SEP13 Comment : "SmptException unhandled by user code." "Failure sending mail." This error occurs in debug at line marked above, "client.Send(message)"
Ok, due to current answers, I changed part of the code to correctly indicate the port, marked above, but now I get the following error.

```
[SocketException (0x271d): An attempt was made to access a socket in a way forbidden by its   access permissions 66.179.170.244:25]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +208
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +464

[WebException: Unable to connect to the remote server]
System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async,   IPAddress& address, Socket& abortSocket, Socket& abortSocket6) +6470692
System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) +307
System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +19
System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +324
System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) +141
System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) +170
System.Net.Mail.SmtpClient.GetConnection() +44
System.Net.Mail.SmtpClient.Send(MailMessage message) +1554

```

"