@page "/contact" @inject HttpClient HttpClient @inject IJSRuntime JSRuntime

Contact

If you think I can help with your project or you'd just like to talk tech, send me a message!

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
@if (isSubmitted) {
@if (sendEmailSuccess) { Thanks for getting in touch! I'll get back to you as soon as I can. } else { Looks like something went wrong trying to send that email. Please try again. }
} @code { private readonly ContactInputModel contactInput = new(); private bool isSubmitting; private bool isSubmitted; private bool sendEmailSuccess; private class ContactInputModel { [Required(ErrorMessage = "Please enter your name.")] [MaxLength(50, ErrorMessage = "Please use a shorter name. 50 characters max.")] public string Name { get; set; } = string.Empty; [Required(ErrorMessage = "Please enter your email.")] [EmailAddress(ErrorMessage = "Please enter a valid email address.")] public string Email { get; set; } = string.Empty; [Required(ErrorMessage = "Please include a message.")] [MaxLength(500, ErrorMessage = "Please enter a shorter message. 500 characters max.")] public string Message { get; set; } = string.Empty; } private async Task HandleValidSubmit() { isSubmitting = true; var recaptchaResponse = await JSRuntime.InvokeAsync("executeRecaptcha"); if (string.IsNullOrWhiteSpace(recaptchaResponse)) { sendEmailSuccess = false; } else { var sendEmailRequest = new SendContactEmailRequest( contactInput.Name, contactInput.Email, contactInput.Message, recaptchaResponse); var response = await HttpClient.PostAsJsonAsync("/api/send-contact-email", sendEmailRequest); sendEmailSuccess = response.IsSuccessStatusCode; } isSubmitting = false; isSubmitted = true; } }