Adding Email Tokens

Adding Email Tokens

This question is not answered

I have a couple extra fields to add the to ContactBlog.ascx form, and while I have them added I cannot seem to find a way to add them into the email.  If anyone knows of a way to do this safely then please let me know.

Here is what the added code looks like:


<li class="field-item">

 

 

<CSControl:FormLabel LabelForId="tbSubject" runat="server" ResourceName="Weblog_ContactForm_OperatingSystem" LabelCssClass="field-item-header" />

 

 

<span class="field-item-input">

 

 

<asp:DropDownList LabelForID="userOS" runat="server/>

 

 

<asp:ListItem Value="Win7(32)">Windows 7 32-Bit</asp:ListItem>

[...others]

 

 

 

</asp:DropDownList></span>

 

 

</li>

 

 

<li class="field-item">

 

 

<CSControl:FormLabel LabelForId="tbSubject" runat="server" ResourceName="Weblog_ContactForm_ApplicationName" LabelCssClass="field-item-header" />

 

 

<span class="field-item-input">

 

 

<asp:DropDownList ID="DropDownList1" LabelForID="userOS" runat="server />

 

 

<asp:ListItem Value="DIYDeck">DIY Deck Designer</asp:ListItem>

 

 

[...others]

 

 

</asp:DropDownList></span>

 

 

</li>


 

Verified Answer
  • As said previously, you need to create your own custom form.  You will likely want to use classes in the System.Net.Mail namespace to convert your form fields into an email to send.

  • Alright, so I've got something that I think will work - thank you by the way, for the direction.  Anyway I have a form and I've uploaded it to the website.  I am getting an error though - I assume it is because its a file I created and I am trying to replace something on CS.  So here is the file I am replacing: ContactBlog.aspx, with another file (same name) only I have added a codefile to it so that it will send email that way.

    I am getting an error on the Inherits attribute:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="~/Utility/ContentFragments/Blogs/ContactBlog.ascx.cs" Inherits="Utility_ContentFragments_Blogs_contact"  %>

    It says to make sure that the Inherits attribute matches the class and extends the correct base class.

    Now I am not sure but it looks like the classes match, but I am not sure what it means that it extends the correct base class, here is my class definition:

    public partial class Utility_ContentFragments_Blogs_contact : CommunityServer.Components.CSPage

    {

    If you need the rest of the code then just let me know, is there an easier way to display it, or maybe attach a txt file?

    Thanks

  • OK, so I got this much to work - I am just using a <script> tag to include the send email code.  It seems to be showing up alright on the page but I am not getting any emails or errors.  So here is what I have in the script tags:

    protected void SendMail(Object sender, EventArgs e)
    {
    MailMessage mail = new MailMessage();
    mail.From = new MailAddress("this.tbEmail.Text");
    //mail.To.Add("designsupport@bighammer.com");
    mail.To.Add("scollins@edgenet.com");
    mail.Subject = "this.tbSubject.Text";
    mail.IsBodyHtml = true;

    mail.Body = "Name: " + "this.tbName.text" + "
    "; mail.Body += "Operating System: " + "this.OSDropDown.text" + "
    "; mail.Body += "Application Name: " + "this.appDropDown.text" + "
    ";
    mail.Body += "Question/Comment:
         "
    + "this.tbBody.text" + "
    ";

    SmtpClient smtp = new SmtpClient();
    smtp.Host = {.{.{smtpServer name in here}.}.};
    smtp.Send(mail);
    }

    If anyone knows what might be going on then I would appreciate the help. Thank you.

  • You shouldn't modify any out of the box widgets as this will cause issues when you come to upgrade.  You should instead write your own widget telligent.com/.../create-new-widgets.aspx .

    As for your email, it could be that the email is never being sent properly, or the email is getting lost in transite.  for the first potential issue, set a breakpoint on the send method and ensure that the smtp.Sent(...) line is actually being called.  For the second issue, try using a tool such as papercut ( http://www.dummysmtp.com/ ) to see the email exactly as it was sent.

  • Alright, I am trying to follow the tutorial (I got the other one working by the way) but it won't let me build the project because of 3 errors:

    Error 1: The type or namespace name 'IMessageDataProvider' could not be found (are you missing a using directive or an assembly reference?)

    Error 2: The type or namespace name 'IActivityMessage' could not be found (are you missing a using directive or an assembly reference?)

    Error 3: The type or namespace name 'IActivityMessage' could not be found (are you missing a using directive or an assembly reference?)

All Replies
  • As said previously, you need to create your own custom form.  You will likely want to use classes in the System.Net.Mail namespace to convert your form fields into an email to send.

  • Alright, so I've got something that I think will work - thank you by the way, for the direction.  Anyway I have a form and I've uploaded it to the website.  I am getting an error though - I assume it is because its a file I created and I am trying to replace something on CS.  So here is the file I am replacing: ContactBlog.aspx, with another file (same name) only I have added a codefile to it so that it will send email that way.

    I am getting an error on the Inherits attribute:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="~/Utility/ContentFragments/Blogs/ContactBlog.ascx.cs" Inherits="Utility_ContentFragments_Blogs_contact"  %>

    It says to make sure that the Inherits attribute matches the class and extends the correct base class.

    Now I am not sure but it looks like the classes match, but I am not sure what it means that it extends the correct base class, here is my class definition:

    public partial class Utility_ContentFragments_Blogs_contact : CommunityServer.Components.CSPage

    {

    If you need the rest of the code then just let me know, is there an easier way to display it, or maybe attach a txt file?

    Thanks

  • OK, so I got this much to work - I am just using a <script> tag to include the send email code.  It seems to be showing up alright on the page but I am not getting any emails or errors.  So here is what I have in the script tags:

    protected void SendMail(Object sender, EventArgs e)
    {
    MailMessage mail = new MailMessage();
    mail.From = new MailAddress("this.tbEmail.Text");
    //mail.To.Add("designsupport@bighammer.com");
    mail.To.Add("scollins@edgenet.com");
    mail.Subject = "this.tbSubject.Text";
    mail.IsBodyHtml = true;

    mail.Body = "Name: " + "this.tbName.text" + "
    "; mail.Body += "Operating System: " + "this.OSDropDown.text" + "
    "; mail.Body += "Application Name: " + "this.appDropDown.text" + "
    ";
    mail.Body += "Question/Comment:
         "
    + "this.tbBody.text" + "
    ";

    SmtpClient smtp = new SmtpClient();
    smtp.Host = {.{.{smtpServer name in here}.}.};
    smtp.Send(mail);
    }

    If anyone knows what might be going on then I would appreciate the help. Thank you.

  • You shouldn't modify any out of the box widgets as this will cause issues when you come to upgrade.  You should instead write your own widget telligent.com/.../create-new-widgets.aspx .

    As for your email, it could be that the email is never being sent properly, or the email is getting lost in transite.  for the first potential issue, set a breakpoint on the send method and ensure that the smtp.Sent(...) line is actually being called.  For the second issue, try using a tool such as papercut ( http://www.dummysmtp.com/ ) to see the email exactly as it was sent.

  • Alright, I am trying to follow the tutorial (I got the other one working by the way) but it won't let me build the project because of 3 errors:

    Error 1: The type or namespace name 'IMessageDataProvider' could not be found (are you missing a using directive or an assembly reference?)

    Error 2: The type or namespace name 'IActivityMessage' could not be found (are you missing a using directive or an assembly reference?)

    Error 3: The type or namespace name 'IActivityMessage' could not be found (are you missing a using directive or an assembly reference?)