Plan1.Controllers.DHBlobController.DHMail C# (CSharp) Метод

DHMail() публичный Метод

public DHMail ( string uri ) : System.Web.Mvc.ActionResult
uri string
Результат System.Web.Mvc.ActionResult
        public ActionResult DHMail(string uri)
        {
            Uri uriCurrent = new Uri(uri);
            string currentStorage = uriCurrent.Segments[0];
            string currentContainer = uriCurrent.Segments[1];
            string currentBlob = uriCurrent.Segments[2];
            currentBlob = currentBlob.Replace("%20", " ");

            string from = "[email protected]";
            var errorMessage = "";
            DHMailResult errMsg = new DHMailResult();
            errMsg.errMessage = errorMessage;

            string toApprover = "[email protected]";

            string server = "mail1.eircom.net";

            errMsg.superV = toApprover;
            MailMessage message = new MailMessage(from, toApprover);
            message.Subject = "Document Link for Planning Review";
            message.Body = "Document link details are as follows:  " + currentStorage + currentContainer + currentBlob;

            SmtpClient client = new SmtpClient(server);
            // Credentials are necessary if the server requires the client
            // to authenticate before it will send e-mail on the client's behalf.
            client.UseDefaultCredentials = true;

            try {
                  client.Send(message);
                }
            catch (Exception ex)
                {
                  errorMessage = ex.Message;
                  errMsg.errMessage = errorMessage;
                }

            return View(errMsg);
        }

Usage Example

 public void DataTest51()
 {
     DHBlobController target = new DHBlobController(); // TODO: Initialize to an appropriate value
     string uri = string.Empty; // TODO: Initialize to an appropriate value
     ActionResult expected = null; // TODO: Initialize to an appropriate value
     ActionResult actual;
     actual = target.DHMail(uri);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }