0

I'm wondering if it's possible to put a foreach loop inside a href?

The reason is because I want a link to be able to link to multiple emails and I don't know how to do it otherwise.

I'm using HTML, Razor

I tried doing like this:

 @foreach (var syv in syvs)
            {
               <a href="mailto:@syv.ePost" target="_top">@syv.ePost</a>

            }

But now it displays all the mails. What I want is one link that mails to all.

I need something that only loops the mails inside the link, but I can't figure out how. I want to send email to multiple people when clicked.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
John
  • 165
  • 1
  • 1
  • 15

1 Answers1

1

I'm not familiar with this language, but you could try something like :

<a href="mailto: @foreach (var syv in syvs) { @syv.ePost }"target="_top">Link to all the mail</a>

Note that I don't know the syntax you are using, I'm just showing the logic here : looping on the href attribute. You'll need to separate each email address with a comma.

enguerranws
  • 8,087
  • 8
  • 49
  • 97