Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kyle Skrinak 272 posts 327 karma points
    Mar 04, 2011 @ 03:53
    Kyle Skrinak
    0

    Allow for more than one recipient?

    Is there a modification that will allow for more than a single "To" recipient from the web form?

    Thanks!

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 04, 2011 @ 06:53
    Sebastiaan Janssen
    2

    Not at the moment. Just grab the source and change:

    mail.To.Add(new MailAddress(GetPropertyFromAlias("contactMailTo")));

    to:

    var toMailAddresses = GetPropertyFromAlias("contactMailTo").Split(',').Trim();
    foreach (string toAddress in toMailAddresses) 
    {
        mail.To.Add(new MailAddress(toAddress));
    }

    Then you can just comma-seperate the recipient addresses.

  • Kyle Skrinak 272 posts 327 karma points
    Mar 04, 2011 @ 16:15
    Kyle Skrinak
    0

    Thanks for your quick response. I presume this means recompiling from source in VS? I haven't done such high-end tasks yet.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 07, 2011 @ 08:40
    Sebastiaan Janssen
    1

    It's not difficult, just get a copy of the source and open up the CultivContactForm.sln file in Visual Studio (you can also use the free VS Express if you don't have VS installed).

    Then just make the code change (fold open te .ascx file to find the .cs file).

    Finally, in the Build menu, choose Build Solution and then have a look in the bin folder of where you unzipped the contact form source, there should be a CultivContactForm.dll. Put that in the bin folder of your website and you should be able to use it just fine.

  • Kyle Skrinak 272 posts 327 karma points
    Mar 07, 2011 @ 13:19
    Kyle Skrinak
    0

    On build I am getting this error;

    "Error 1 'System.Array' does not contain a definition for 'Trim' and no extension method 'Trim' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?) C:\Users\spookytoast\Downloads\cultivcontactform-57140\CultivContactForm\UserControl\CultivContactForm.ascx.cs 76 84 CultivContactForm"
  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 08, 2011 @ 12:22
    Sebastiaan Janssen
    0

    Of course, that was silly of me, the Trim() is in the wrong place, try this:

                var toMailAddresses = GetPropertyFromAlias("contactMailTo").Split(',');
                foreach (string toAddress in toMailAddresses)
                {
                    mail.To.Add(new MailAddress(toAddress.Trim()));
                }
  • Kyle Skrinak 272 posts 327 karma points
    Mar 08, 2011 @ 17:11
    Kyle Skrinak
    0

    Alright, compiled that time, but now I'm getting a validation error in the admin UI that the mail format is wrong. ("Your data has been saved, but before you can publish this page there are some errors you need to fix first")

    (If you're reading along, later we discuss that you'll ALSO have to update your form validation in the docType for your contact page... fyi)

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 10, 2011 @ 12:17
    Sebastiaan Janssen
    1

    Hey Kyle, sorry for the late reply, I didn't get a notification email about it.

    This is a strange error, are you using strange characters in the e-mail addresses? Like ø or ñ? Have you tried with a single e-mail address? And have you tried fictional addresses like [email protected],[email protected]

     

  • Kyle Skrinak 272 posts 327 karma points
    Mar 10, 2011 @ 13:12
    Kyle Skrinak
    0

    No apologies necessary, I appreciate your attention!

    I rebuilt the .dll and overwrote the existing one again, just to be sure. I tried your varients in the mail address, same error. A single, "non-split" address works fine. Wouldn't form validation live elsewhere than how a field is parsed?

  • kows 81 posts 151 karma points c-trib
    Mar 10, 2011 @ 13:28
    kows
    1

    check out the CultivContactForm document type,

    it has a property contactMailTo with next validation set:

    [a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?

    remove validation or update it so it accepts ','-seperated e-mails,

    then you'll be able to save in your backoffice.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 10, 2011 @ 14:07
    Sebastiaan Janssen
    1

    D'oh of course! I should've remembered that! ;-)

  • Kyle Skrinak 272 posts 327 karma points
    Mar 10, 2011 @ 15:55
    Kyle Skrinak
    0

    I hate it when this forum eats my posts.

    That did the trick nicely. Here's the extended regex to allow for more than one comma-delimited email addresses:

    ([a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?,?)+[^,]

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft