hello, i have an issue, contact us in webapplication aspnet webform
i have an advertise website, in which people put their ads and they contact echother by any form of email address. the same when people will contact me with their defaqult email address. in my case, the problem is the client's creditial and host, which must be specific or defined. but how make it default or general?
protected void btnSend_Click(object sender, EventArgs e)
{
MailMessage message = new MailMessage(txtEmail.Text, emailto, txtSubject.Text, txtBody.Text); //creates a mail message
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient
{
Port = 25, //any client
Host = "smtp.gmail.com",//"smtp-mail.outlook.com", //"smtp.sendgrid.net", //or another email sender provider
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = true,
Credentials = new NetworkCredential("[email protected]", 'my secret password') //but it must be sender, not me
};
try
{
client.Send(message);
lblResult.Text = "your mail has been sent successfully!";
}
catch (Exception ex) { lblResult.Text = ex.Message; }
finally { btnSend.Enabled = true; clearFields(); }
}
//////////////////////////////////////////////
i used another way, i made droppdownlist with different hosts (what stands after @ sign in email) and i used
client.Credentials = new NetworkCredential(txtEmail.Text, txtPassword.Text, domain);
but didn't worked??!!
how should i make default host??!! appreciate your respond, with codes. very kind regards
Matthias MuellerPosted Aug 7, 2024, 3:47 AM
When setting up a "Contact Us" feature in a C# ASP.NET WebForms application, configuring the email domain properly is crucial. It’s a top search topic for developers looking to ensure reliable email delivery. Proper configuration of the email domain helps avoid issues with email delivery and spam filters, making sure that user inquiries are received and addressed efficiently.
Prasad RaveendranPosted Aug 7, 2024, 2:41 AM
good to hear that issue has been resolved
venus najadPosted Aug 6, 2024, 8:10 PM
the problem is solved using sendgrid...
venus najadPosted Aug 5, 2024, 5:54 PM
sorry, i add that other domain's port are 25...
if sendgrid covers other email domain, then i use 25 for its port. shouldn't i?
venus najadPosted Aug 5, 2024, 5:52 PM
hello mr Raveendran and thanksc for your respond...
as you know, people has different email domain. many hyas their websites email domain, many has their jobs email domain...
is sendgrid cover the rest of email domain than gmail and outlook? how should i define sendgrid in the projekt? or sendgrid is known in C#?
appreciate your respond... kind regards
Prasad RaveendranPosted Aug 4, 2024, 4:35 PM
To make your email sending functionality more flexible and user-friendly, you can implement a way to allow users to send emails using their own email credentials. Here’s how you can achieve this:
SmtpClient.Here's a sample implementation:
Note:
ddlEmailProvideris a dropdown list containing the supported email providers (e.g., Gmail, Outlook, SendGrid).HTML Code