Skip to content
Loading
 
+2
  • Sachin Singh
    +2
    on submit , are values binding to the model properties? I think values are not binding with the model properties.
    change submit button to asp button and send the form as you usually do that is onpost and under onpost method call your mailsending method.
    +2
  • Marius Vasile
    +2
    data is sent from the form because at the same time I am writting those values to a table and send email with string only
     
    1. var message = new MimeMessage();  
    2.             message.From.Add(new MailboxAddress(_smtpSettings.SenderName, _smtpSettings.SenderEmail));  
    3.             message.To.Add(new MailboxAddress("[email protected]"));  
    4.             message.ReplyTo.Add(new MailboxAddress("[email protected]"));  
    5.             message.Subject = "Contact form communication";  
    6.   
    7.   
    8.             message.Body = new TextPart("html")  
    9.             {  
    10.                 Text = "text"  
    11.             };  
    12.   
    13.   
    14.   
    15.             using (var client = new SmtpClient())  
    16.             {  
    17.                 await client.ConnectAsync(_smtpSettings.Server, _smtpSettings.Port, true);  
    18.   
    19.                 client.AuthenticationMechanisms.Remove("XOAUTH2");  
    20.   
    21.                 await client.AuthenticateAsync(_smtpSettings.UserName, _smtpSettings.Password);  
    22.                 await client.SendAsync(message);  
    23.                 await client.DisconnectAsync(true);  
    24.             }  
     
    +2