Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6323075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:27:04+00:00 2026-05-24T16:27:04+00:00

Im having a problem using Email.SendMail(). I need to add more details like Event_Location,

  • 0

Im having a problem using Email.SendMail(). I need to add more details like Event_Location, Event_Start, etc to the “Email Msg” from the Events table in the database but the var item is already called by events. I would like to know if there is a way to put two var i.e events and members either in the foreach loop or another method?

public void Send()
{
   var events = from a in db.Members.ToList()
                join e in db.Events.ToList() on a.Hobby_Code equals e.Hobby_Code
                where a.Postal_Code == e.Postal_Code || e.Event_Status ==("A")

   var member= from w in db.Members.TOList()
               join z in db.Events.ToList() on w.Event_ID equals z.Event_ID
               select w

   foreach (var item in events)
      Email.SendMail(item.Member_Email_Address,"Subject","Email Msg",false);
}

Model Class for Member

  public class Member
  {
    [Key]
    [ScaffoldColumn(false)]
    public int Member_ID { get; set; }



    [Required(ErrorMessage = "A Section Name is required")]
    [DisplayName("Section Name")]
    public string Postal_Code { get; set; }


    [Required(ErrorMessage = "An email address is required")]
    [DisplayName("Email Address")]
    public string Member_Email_Address { get; set; }



    [DisplayName("Hobby Code")]
    [Required(ErrorMessage = "A Hobby is required")]
    public string Hobby_Code { get; set; }

    [DisplayName("Event ID")]
    public int? Event_ID { get; set; }

    public string FullName
    {
        get
        {
            return Member_Last_Name + " " + Member_First_Name;
        }
    }


    public virtual Section Section { get; set; }
    public virtual Event Event { get; set; }

}

Model Class for Event

     public class Event 
{

    [ScaffoldColumn(false)]
    [Key]
    public int Event_ID { get; set; }

    [Required(ErrorMessage = "A Event Location is required")]
    [DisplayName("Event Location")]
    public string Postal_Code { get; set; }

    [DisplayName("Event Status")]
    public string Event_Status { get; set; }

    [DisplayName("Event Start Date")]
    [Required]
    public DateTime Event_Start { get; set; }

    [DisplayName("Event End Date")]
    [Required]
    public DateTime Event_End { get; set; }

    [DisplayName("Event Type")]
    [Required(ErrorMessage = "A Event Type is required")]
    public string Hobby_Code { get; set; }

    [Required]
    [StringLength(100)]
    [DataType(DataType.MultilineText)]
    [DisplayName(" Event Description")]
    public string Event_Description { get; set; }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:27:04+00:00Added an answer on May 24, 2026 at 4:27 pm

    you can use an anonymous method to return only those properties you want, i.e.:

    var events = from a in db.Members.ToList()
                    join e in db.Events.ToList() on a.Hobby_Code equals e.Hobby_Code             
                    where a.Postal_Code == e.Postal_Code || e.Event_Status ==("A")
                    select new { email = a.Member_Email_Address, location = e.Event_Location, eventStart = e.Event_Start};
    

    and then access it in the for loop like so:

    foreach (var item in events)      
        Email.SendMail(item.email,"Subject",String.Format("Location: {0}",item.location),false); // including all the other variables required and excluding the formatting
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem with a POST I'm doing using the HttpWebRequest object from
I am having a problem inserting and removing objects to/from the database using Linq
I'm having problem sending an attachment via email using smtp client. It sends great
I'm having a problem using the java.text.MessageFormat object. I'm trying to create SQL insert
I am having a problem using the Unity Application Block, I have created a
I'm having a problem using CSS's display:inline property with the list-style-image: property on <li>
I'm having a problem running a T4 template using TextTransform.exe on my build server.
I'm having a problem writing Norwegian characters into an XML file using C#. I
I am using the tablesorter plugin ( http://tablesorter.com ) and am having a problem
I'm using Intelligencia's UrlRewriter in my application and I'm having a problem where the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.