none
Passing a Value From Submitted Input into the Subject Line? RRS feed

  • Question

  • I have been trying to figure this out, but I am having some trouble. All i want to do is take a value which is submitted in my form and then place that value inside of the subject line in the email. This is very simple.

    Can someone please give me an actual example of this?

    Here is my code below:

    const string SERVER = "10.111.8.177"; 
       const string txtEmail = "mail@yahoo.com";
       const string ITSSPSubject = "Passing subject" + "requestor_name.Value"; 
       MailMessage oMail = new System.Net.Mail.MailMessage();
       oMail.Headers.Add("Content-Transfer-Encoding","base64");
       oMail.Attachments.Add(System.Net.Mail.Attachment.CreateAttachmentFromString(ITSPPSoftwareProcurementProcessRequest, "ITSPPSoftwareProcurementProcessRequest.html"));
       oMail.From = new System.Net.Mail.MailAddress("mail@yahoo.com");
       oMail.To.Add("mail@gmail.com");
       oMail.set_Subject(ITSSPSubject);
       oMail.IsBodyHtml = true;
       oMail.Priority = MailPriority.High; // enumeration
       oMail.Body = "Sent at: " + DateTime.Now + "\r\n\r\n" ;
       SmtpClient smtp = new SmtpClient("10.111.8.177");
       smtp.Send(oMail);
       oMail = null; // free up resources 


    Saturday, August 9, 2014 9:42 PM

Answers

  • Set the Subject property to the following string then:

    oMail.Subject = string.Format("Subdomain.site.com - {0}  - IT Software Procurement Process Request Form", requestor_name.Value);
     MailMessage oMail = new System.Net.Mail.MailMessage(
                    "Mailfrom@mail.com",
                    "Mailto@mail.com"
                    );
    
                oMail.Subject = string.Format("Subdomain.site.com - {0}  - IT Software Procurement Process Request Form", requestor_name.Value);
      oMail.Body = ITSPPSoftwareProcurementProcessRequest;
    
                oMail.Headers.Add("Content-Transfer-Encoding", "base64");
                oMail.Attachments.Add(System.Net.Mail.Attachment.CreateAttachmentFromString(ITSPPSoftwareProcurementProcessRequest, "ITSPPSoftwareProcurementProcessRequest.html"));
                oMail.IsBodyHtml = true;
                oMail.Priority = MailPriority.High; // enumeration
                ...
    


    Monday, August 11, 2014 11:01 AM

All replies

  • Let said your subject is a TextBox in WinForm or ASP.NET you can just do

    oMail.set_Subject = txtSubject.Text;

    The concept is basically the same to pass the content of a control to your subject. WPF will be.

    oMail.set_Subject = txtSubject.Content;

    chanmm


    chanmm

    Sunday, August 10, 2014 2:15 AM
  • tried that and now I get : CS0571: 'System.Net.Mail.MailMessage.Subject.set': cannot explicitly call operator or accessor

    Line 361:   oMail.set_Subject = txtSubject.Content;

    const string Content = "subdomain.site.com + " - " + "requestor_name.Value" + " - " + "IT Software Procurement Process Request Form";

    I am trying to pass the requestor_name.Value into the subject line.

    Sunday, August 10, 2014 7:42 AM
  • const string Content

    const is your problem.

    You can't change a constant.

    As it's name suggests really.

    Make that

    string Content

    Sunday, August 10, 2014 9:46 AM
    Moderator
  • Okay know i've got : CS0571: 'System.Net.Mail.MailMessage.Subject.set': cannot explicitly call operator or accessor

    oMail.set_Subject = txtSubject.Content;
    
       string Content = "Subdomain.site.com" + " - " + "ITSPPSoftwareProcurementProcessRequest.requestor_name.Value" + " - " + "IT Software Procurement Process Request Form";



    Sunday, August 10, 2014 11:51 AM
  • Hello,

    Here is a simple example, simply pass in the information i.e. from, to, subject etc.

    using System.Net.Mail;
    namespace ClassLibrary1
    {
        internal class MailSample
        {
            private MailSample()
            { 
            }
            private void SendMessage(
                string FromAddress, 
                string TooAddress, 
                string Subject, 
                string Body, 
                string Content,
                string mName,
                string TheHost)
            {
                using (MailMessage Message = new MailMessage())
                {
                    Message.Priority = MailPriority.High;
    
                    Message.From = new MailAddress(FromAddress);
                    Message.To.Add(new MailAddress(TooAddress));
                    Message.Subject = Subject;
    
                    Message.Body = Body;
                    Message.IsBodyHtml = true;
    
                    Message.Attachments.Add(Attachment.CreateAttachmentFromString(Content,mName));
    
                    SmtpClient MailClient = new SmtpClient(TheHost);
                    MailClient.UseDefaultCredentials = true ;
                    MailClient.Send(Message);
                }
            }
        }
    }


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Sunday, August 10, 2014 12:23 PM
    Moderator
  • This doesnt match what i am looking for. This also already available which i have seen. Anyone else, can look at my code and tell me what i need to do to make it work?

    CS0571: 'System.Net.Mail.MailMessage.Subject.set': cannot explicitly call operator or accessor

    Line 361:   oMail.set_Subject = new System.Net.Mail.MailMessage.Subject("txtSubject.Content");

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System" %>
    <%@ Import Namespace="System.Net.Mail" %>
    <%@ Import Namespace="System.IO" %>
    <%@ Import Namespace="System.Net.Mime" %>
    <%@ Assembly Name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" %>
    <%@ Assembly Name="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %>
    <%@ Register TagPrefix="corpIT_header" TagName="design" Src="header.ascx" %>
    <%@ Register TagPrefix="corpIT_header" TagName="css" Src="css.ascx" %>
    <%@ Register TagPrefix="corpIT_header" TagName="footer" Src="footer.ascx" %>
    <script language="C#" runat=server >
    private void btnSendmail_Click(object sender, EventArgs e)
    {
       string ITSPPSoftwareProcurementProcessRequest = String.Empty;
    
    
       System.IO.Stream streamITSPPSoftwareProcurementProcessRequest = new System.IO.MemoryStream();
       System.IO.MemoryStream memorystreamITSPPSoftwareProcurementProcessRequest = new System.IO.MemoryStream();
       System.IO.StreamWriter writer = new System.IO.StreamWriter(memorystreamITSPPSoftwareProcurementProcessRequest);
       System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Text.Html);
       System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(streamITSPPSoftwareProcurementProcessRequest, ct);
       attach.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
       attach.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
       attach.ContentDisposition.FileName = "ITSPPSoftwareProcurementProcessRequest.txt";
       ContentDisposition disposition = attach.ContentDisposition;
       disposition.FileName = "oMail" + DateTime.Now.ToString();
       writer.Write("Hello its my sample file");
       
    
       
       const string SERVER = "10.111.8.177";
       const string txtEmail = "mail@yahoo.com";
       string Content = "subdomain.site.com" + " - " + "ITSPPSoftwareProcurementProcessRequest.requestor_name.Value" + " - " + "IT Software Procurement Process Request Form";
       MailMessage oMail = new System.Net.Mail.MailMessage();
       oMail.Headers.Add("Content-Transfer-Encoding","base64");
       oMail.Attachments.Add(System.Net.Mail.Attachment.CreateAttachmentFromString(ITSPPSoftwareProcurementProcessRequest, "ITSPPSoftwareProcurementProcessRequest.html"));
       oMail.From = new System.Net.Mail.MailAddress("mail@yahoo.com");
       oMail.To.Add("mail@gmail.com");
       oMail.set_Subject = txtSubject.Content;
       oMail.IsBodyHtml = true;
       oMail.Priority = MailPriority.High; // enumeration
       oMail.Body = "Sent at: " + DateTime.Now + "\r\n\r\n" ;
       SmtpClient smtp = new SmtpClient("10.111.8.177");
       smtp.Send(oMail);
       oMail = null; // free up resources 
     
       writer.Flush();
       writer.Dispose(); 
       memorystreamITSPPSoftwareProcurementProcessRequest.Close();
       Response.Redirect ("thankyou.aspx");
    }
    

    Sunday, August 10, 2014 1:46 PM
  • In your other thread I posted some code.

    Here it is again.

             string ITSPPSoftwareProcurementProcessRequest = "whatever you want";
    
                MailMessage oMail = new System.Net.Mail.MailMessage(
                    "mailfrom@mail.com",
                    "mailto@mail.com",
                    "Sent at: " + DateTime.Now + "\r\n\r\n" + ITSPPSoftwareProcurementProcessRequest, // duplicates attachment ??????
                    "request.system.com - Procurement Process Request Form"
                    );
                Attachment att = Attachment.CreateAttachmentFromString(ITSPPSoftwareProcurementProcessRequest, "AttachmentName.txt");
                oMail.Attachments.Add(att);
                oMail.BodyEncoding = System.Text.Encoding.UTF8;  
                oMail.Priority = MailPriority.High; // enumeration
                SmtpClient smtp = new SmtpClient("10.111.8.177");
                smtp.Send(oMail);

    See that bold 4th parameter of the constructor?

     "request.system.com - Procurement Process Request Form"
    

    You need to change just that.

    In your last piece of code

    ITSPPSoftwareProcurementProcessRequest is just a string you build.

    In there requestor_signed_name.Value is the name. Looks  like you've got a bit confused..

       "Subdomain.site.com - " + requestor_signed_name.Value  + " - IT Software Procurement Process Request Form"

    Sunday, August 10, 2014 1:49 PM
    Moderator

  • Try to put:

    string Content = "Subdomain.site.com" + " - " + "ITSPPSoftwareProcurementProcessRequest.requestor_name.Value" + " - " + "IT Software Procurement Process Request Form";
    oMail.Subject = Content;

    or:

    oMail.Subject =  txtSubject.Text;

    before this line of code:

    smtp.Send(oMail);
    

    Sunday, August 10, 2014 2:30 PM
  • I've modified .Value to match requestor_name and still get the same error. Am i still missing something? When i do the output i use the CustomizedName.Value throughout to call the values from the input form.

       string Content = "Subdomain.site.com" + " - " + "ITSPPSoftwareProcurementProcessRequest.requestor_name.requestor_name" + " - " + "AFS IT Software Procurement Process Request Form";
    
    oMail.set_Subject = txtSubject.Content;

    OR are you saying i need to change

    MailMessage oMail = new System.Net.Mail.MailMessage()

    so that it includes specifying the value with the 4 parameters? i.e. below and that will force the value to show in the subject line?

    MailMessage oMail = new System.Net.Mail.MailMessage(
                    "mailfrom@mail.com",
                    "mailto@mail.com",
                    "Sent at: " + DateTime.Now + "\r\n\r\n" + ITSPPSoftwareProcurementProcessRequest, 
                    requestor_name + "Subject line - Procurement Process Request Form"
                    );

    Sunday, August 10, 2014 2:35 PM
  • I mean like this:

                MailMessage oMail = new System.Net.Mail.MailMessage(
                    "mailfrom@mail.com",
                    "mailto@mail.com",
                    "Sent at: " + DateTime.Now + "\r\n\r\n" + ITSPPSoftwareProcurementProcessRequest, // duplicates attachment ??????
                   
                    "Subdomain.site.com - " + requestor_signed_name.Value  + " - IT Software Procurement Process Request Form"
    
                    );
                Attachment att = Attachment.CreateAttachmentFromString(ITSPPSoftwareProcurementProcessRequest, "AttachmentName.txt");
                oMail.Attachments.Add(att);
                oMail.BodyEncoding = System.Text.Encoding.UTF8;  
                oMail.Priority = MailPriority.High; // enumeration
                SmtpClient smtp = new SmtpClient("10.111.8.177");
                smtp.Send(oMail);

    Sunday, August 10, 2014 2:49 PM
    Moderator
  • so I've done that now i am getting the following:

    Exception Details: System.ArgumentException: The specified string is not in the form required for a subject.

    Line 356:   MailMessage oMail = new System.Net.Mail.MailMessage(
    <script language="C#" runat=server >
    private void btnSendmail_Click(object sender, EventArgs e)
    {
       string ITSPPSoftwareProcurementProcessRequest = String.Empty;
       
       
    
       System.IO.Stream streamITSPPSoftwareProcurementProcessRequest = new System.IO.MemoryStream();
       System.IO.MemoryStream memorystreamITSPPSoftwareProcurementProcessRequest = new System.IO.MemoryStream();
       System.IO.StreamWriter writer = new System.IO.StreamWriter(memorystreamITSPPSoftwareProcurementProcessRequest);
       System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Text.Html);
       System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(streamITSPPSoftwareProcurementProcessRequest, ct);
       attach.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
       attach.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
       attach.ContentDisposition.FileName = "ITSPPSoftwareProcurementProcessRequest.txt";
       ContentDisposition disposition = attach.ContentDisposition;
       disposition.FileName = "oMail" + DateTime.Now.ToString();
       writer.Write("Hello its my sample file");
       
    
       
       const string SERVER = "10.111.8.177";
       const string txtEmail = "mailfrom@mail.com";
       MailMessage oMail = new System.Net.Mail.MailMessage(
                    "Mailfrom@mail.com",
                    "Mailto@mail.com",
                    "Sent at: " + DateTime.Now + "\r\n\r\n" + ITSPPSoftwareProcurementProcessRequest, // duplicates attachment ??????
                    "Subdomain.site.com - " + requestor_name.Value  + " - IT Software Procurement Process Request Form"
    
                    );
       oMail.Headers.Add("Content-Transfer-Encoding","base64");
       oMail.Attachments.Add(System.Net.Mail.Attachment.CreateAttachmentFromString(ITSPPSoftwareProcurementProcessRequest, "ITSPPSoftwareProcurementProcessRequest.html"));
       oMail.IsBodyHtml = true;
       oMail.Priority = MailPriority.High; // enumeration
       SmtpClient smtp = new SmtpClient("10.111.8.177");
       smtp.Send(oMail);
       oMail = null; // free up resources 
     
       writer.Flush();
       writer.Dispose(); 
       memorystreamITSPPSoftwareProcurementProcessRequest.Close();
       Response.Redirect ("thankyou.aspx");
    }
    
    </script>

    Sunday, August 10, 2014 3:22 PM
  • Probably just due to no conversion on datetime.

    In fact I'm a bit surprised it doesn't give you an error specifically about that now I come to think about it.

    Datetime.Now is Datetime rather than string.

      "Sent at: " + DateTime.Now.ToString() + ITSPPSoftwareProcurementProcessRequest, 

    I have no smtp server available, so I can't actually test this stuff properly.

    When I make that change, try using

    smtp-mail.outlook.com

     and spin it up I get an error on the send which I'm fairly confident is because it can't get past my firewall.

    Sunday, August 10, 2014 3:50 PM
    Moderator
  • So now the page displays but after i fill out my form and hit submit, it tells me that :

    Exception Details: System.ArgumentException: The specified string is not in the form required for a subject.

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System" %>
    <%@ Import Namespace="System.Net.Mail" %>
    <%@ Import Namespace="System.IO" %>
    <%@ Import Namespace="System.Net.Mime" %>
    <%@ Assembly Name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" %>
    <%@ Assembly Name="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %>
    <%@ Register TagPrefix="corpIT_header" TagName="design" Src="header.ascx" %>
    <%@ Register TagPrefix="corpIT_header" TagName="css" Src="css.ascx" %>
    <%@ Register TagPrefix="corpIT_header" TagName="footer" Src="footer.ascx" %>
    <script language="C#" runat=server >
    private void btnSendmail_Click(object sender, EventArgs e)
    {
       string ITSPPSoftwareProcurementProcessRequest = String.Empty;
       
    
       System.IO.Stream streamITSPPSoftwareProcurementProcessRequest = new System.IO.MemoryStream();
       System.IO.MemoryStream memorystreamITSPPSoftwareProcurementProcessRequest = new System.IO.MemoryStream();
       System.IO.StreamWriter writer = new System.IO.StreamWriter(memorystreamITSPPSoftwareProcurementProcessRequest);
       System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Text.Html);
       System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(streamITSPPSoftwareProcurementProcessRequest, ct);
       attach.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
       attach.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
       attach.ContentDisposition.FileName = "ITSPPSoftwareProcurementProcessRequest.txt";
       ContentDisposition disposition = attach.ContentDisposition;
       disposition.FileName = "oMail" + DateTime.Now.ToString();
       writer.Write("Hello its my sample file");
       
    
       
       const string SERVER = "10.111.8.177";
       const string txtEmail = "mailfrom@mail.com";
       MailMessage oMail = new System.Net.Mail.MailMessage(
                    "mailfrom@mail.com",
                    "mailto@mail.com",
                    "Sent at: " + DateTime.Now.ToString() + "\r\n\r\n" + ITSPPSoftwareProcurementProcessRequest, // duplicates attachment ??????
                   
                    "Subdomain.site.com - " + requestor_name.Value  + " - IT Software Procurement Process Request Form"
    
                    );
       oMail.Headers.Add("Content-Transfer-Encoding","base64");
       oMail.Attachments.Add(System.Net.Mail.Attachment.CreateAttachmentFromString(ITSPPSoftwareProcurementProcessRequest, "ITSPPSoftwareProcurementProcessRequest.html"));
       oMail.IsBodyHtml = true;
       oMail.Priority = MailPriority.High; // enumeration
       SmtpClient smtp = new SmtpClient("10.111.8.177");
       smtp.Send(oMail);
       oMail = null; // free up resources 
     
       writer.Flush();
       writer.Dispose(); 
       memorystreamITSPPSoftwareProcurementProcessRequest.Close();
       Response.Redirect ("thankyou.aspx");
    }
    
    </script>

    Sunday, August 10, 2014 4:00 PM
  • Look at my last post again.

     "Sent at: " + DateTime.Now.ToString() + ITSPPSoftwareProcurementProcessRequest, 
    

    You left this stuff in:

     + "\r\n\r\n" 

    Sunday, August 10, 2014 5:52 PM
    Moderator
  • I tried taking the date completely out and it still renders the same error:

    Exception Details: System.ArgumentException: The specified string is not in the form required for a subject.

    const string SERVER = "10.111.8.177";
       const string txtEmail = "mailfrom@mail.com";
       MailMessage oMail = new System.Net.Mail.MailMessage(
                    "mailfrom@mail.com",
                    "mailto@mail.com",
                    ITSPPSoftwareProcurementProcessRequest, // duplicates attachment ??????
                   
                    "Subdomain.site.com - " + requestor_name.Value  + " - IT Software Procurement Process Request Form"
    
                    );

    Sunday, August 10, 2014 6:55 PM
  • It's the third argument specifies the subject (http://msdn.microsoft.com/en-us/library/5k0ddab0(v=vs.110).aspx).  Also, please refer to this page for more information about the " The specified string is not in the form required for a subject" exception: http://blog.dotsmart.net/2008/02/15/systemnetmail-the-specified-string-is-not-in-the-form-required-for-a-subject/

    Try this:

    const string SERVER = "10.111.8.177";
       const string txtEmail = "mailfrom@mail.com";
    string subject =  "Sent at: " + DateTime.Now + "\r\n\r\n" + ITSPPSoftwareProcurementProcessRequest;
    subject = subject.Replace('\r', ' ').Replace('\n', ' ');
       MailMessage oMail = new System.Net.Mail.MailMessage(
                    "Mailfrom@mail.com",
                    "Mailto@mail.com",
                    subject,
                    "Subdomain.site.com - " + requestor_name.Value  + " - IT Software Procurement Process Request Form"
    
                    );
    

    Or, you could set the Subject prooperty after you have created the MailMessage object:

               
     MailMessage oMail = new System.Net.Mail.MailMessage(
                    "Mailfrom@mail.com",
                    "Mailto@mail.com"
                    );
    
                string subject =  "Sent at: " + DateTime.Now + "\r\n\r\n" + ITSPPSoftwareProcurementProcessRequest;
                subject = subject.Replace('\r', ' ').Replace('\n', ' ');
                oMail.Subject = subject;
    
                oMail.Headers.Add("Content-Transfer-Encoding", "base64");
                oMail.Attachments.Add(System.Net.Mail.Attachment.CreateAttachmentFromString(ITSPPSoftwareProcurementProcessRequest, "ITSPPSoftwareProcurementProcessRequest.html"));
                oMail.IsBodyHtml = true;
                oMail.Priority = MailPriority.High; // enumeration
                ...
    

    Monday, August 11, 2014 7:08 AM
  • I tried taking the date completely out and it still renders the same error:

    Exception Details: System.ArgumentException: The specified string is not in the form required for a subject.

    const string SERVER = "10.111.8.177";
       const string txtEmail = "mailfrom@mail.com";
       MailMessage oMail = new System.Net.Mail.MailMessage(
                    "mailfrom@mail.com",
                    "mailto@mail.com",
                    ITSPPSoftwareProcurementProcessRequest, // duplicates attachment ??????
                   
                    "Subdomain.site.com - " + requestor_name.Value  + " - IT Software Procurement Process Request Form"
    
                    );

    The error isn't exactly obscure mate.

    It doesn't like whatever string you're giving it.

    ITSPPSoftwareProcurementProcessRequest has something in it which it doesn't like.

    What did you put in there?

    And is that really what you'd expect as the subject of an email?

    Is it the entire ticket converted to html?

    Because that's a huge long string and it's html. It isn't going to like either.

    Try substituting "X" and see what happens.

    Then think about what you really want to put as the subject of an email.

    If it errors, put a break point in and see what is actually happening.

    Monday, August 11, 2014 7:24 AM
    Moderator
  • okay, so the entire ticket I have coming in the Well-Formed HTML attachment. That is working perfectly. When i substitute X it changes the whole subject line and it works with " X " as the subject.

    What I want to acomplish is give my Email Message a Customized subject line which includes:

    "Subdomain.site.com - John Smith  - IT Software Procurement Process Request Form"

    With John Smith actually being the output of the input which was captured in the <input> as:  " requestor_name.Value "

    So in other words, I just want to include the persons name in the subject line, so we know who's submitting without even opening the email or attachment.

    Monday, August 11, 2014 10:54 AM
  • Set the Subject property to the following string then:

    oMail.Subject = string.Format("Subdomain.site.com - {0}  - IT Software Procurement Process Request Form", requestor_name.Value);
     MailMessage oMail = new System.Net.Mail.MailMessage(
                    "Mailfrom@mail.com",
                    "Mailto@mail.com"
                    );
    
                oMail.Subject = string.Format("Subdomain.site.com - {0}  - IT Software Procurement Process Request Form", requestor_name.Value);
      oMail.Body = ITSPPSoftwareProcurementProcessRequest;
    
                oMail.Headers.Add("Content-Transfer-Encoding", "base64");
                oMail.Attachments.Add(System.Net.Mail.Attachment.CreateAttachmentFromString(ITSPPSoftwareProcurementProcessRequest, "ITSPPSoftwareProcurementProcessRequest.html"));
                oMail.IsBodyHtml = true;
                oMail.Priority = MailPriority.High; // enumeration
                ...
    


    Monday, August 11, 2014 11:01 AM
  • Ahhh haaaa... :) It works...

    So, this "    {0}     " is what i needed? But what i dont get is, why would i have needed to seperate those "Mailfrom@mail.com","Mailto@mail.com" fields from them being their own oMail? Just curious.

    Monday, August 11, 2014 11:13 AM
  • Well, you could also pass the subject to the constructor overload that takes four arguments:

    MailMessage oMail = new System.Net.Mail.MailMessage(
                    "Mailfrom@mail.com",
                    "Mailto@mail.com",
     string.Format("Subdomain.site.com - {0}  - IT Software Procurement Process Request Form", requestor_name.Value),
    ITSPPSoftwareProcurementProcessRequest
                    );


    Note that the subject is the THIRD argument. But please don't ask several questions in the same thread and please also remember to mark helpful posts as answer.

    Monday, August 11, 2014 11:35 AM
  • Ahhh haaaa... :) It works...

    So, this "    {0}     " is what i needed? But what i dont get is, why would i have needed to seperate those "Mailfrom@mail.com","Mailto@mail.com" fields from them being their own oMail? Just curious.

    There's nothing magical about {0} it indicates a parameter for string.Format.

    ITSPPSoftwareProcurementProcessRequest is a string for example.

    Anything that's a string gets methods string has.

    Format is one of those methods.

    http://msdn.microsoft.com/en-us/library/system.string.format(v=vs.110).aspx

    .

    Please don't forget to up vote posts which are helpful or which you like and mark the one(s) which answer your question.

    As you do so you might want to consider relative effort.


    Monday, August 11, 2014 12:04 PM
    Moderator
  • Thanks guys, you have been truly helpful. Andy I will go back and Up your " Votes " count in the previous thread.
    Monday, August 11, 2014 12:11 PM