lundi 11 juillet 2022

Blazor server C#

I am writing a code to send an email with the attached photos. I upload the photos but I want to choose some of them to send by using the checkbox. Can anyone help me, please? This is my code that sends all the photos together.

enter code here

<MudTextField @bind-Value="mod.ReceiversAddress" Label="TO" Variant="Variant.Outlined" Class="mt-10">

   <MudGrid Class="d-flex justify-center flex-grow-1 gap-4">    <MudItem xs="12" sm="6" md="4">
   <MudTextField @bind-Value="mod.subject" Label="Subject" Variant="Variant.Outlined"></MudTextField>
   </MudItem> </MudGrid> <MudGrid Class="d-flex justify-center flex-grow-1 gap-4">
<MudItem xs="12" sm="6" md="4"> <MudTextField T="string" @bind-Value="mod.body" Label="Message" Variant="Variant.Outlined"    Lines="10" /> </MudItem> </MudGrid>
   <MudGrid Class="d-flex justify-center flex-grow-1 gap-4"> <MudButton    Variant="Variant.Filled" EndIcon="@Icons.Material.Filled.Send"    Color="Color.Primary" OnClick="Send" Class=" mt-10    mb-10">Send</MudButton> </MudGrid>
   @foreach (var rose in test){
<MudImage Src="@rose" Width="100" Height="100" Alt="flowers" Elevation="25" Class="mx-auto"/>
 <MudCheckBox @bind-Checked="@Dense_CheckBox" Dense="true" Color="Color.Success"></MudCheckBox>
  }  
   <MudGrid Class="d-flex justify-center flex-grow-1 gap-4"> <MudButton    Variant="Variant.Filled" EndIcon="@Icons.Material.Filled.Send"    Color="Color.Primary" OnClick="Attachment"    Class="mt-10">Attachment</MudButton> </MudGrid>


   @code {

   protected override void OnInitialized()    {
   Remove();    }
   string[] flowers = Directory.GetFiles("wwwroot\\sss");

   List<string> test = new();

   EmailModel mod = new EmailModel();
   public void Send()    {

   SendingEmail.SendEmail(mod);
   }
   public bool Dense_CheckBox { get; set; } = true;


   public void Attachment()    {


   SendingEmail.AtachFile(mod);
   }    //images array to display just sss from the path    string[] path= Directory.GetFiles("wwwroot\\sss");

   public void Remove()    {
   foreach( var item in path)
   {
       var y = item.Remove(0, 8);
       test.Add(y);
       

   }    }



Aucun commentaire:

Enregistrer un commentaire