I am facing very confusing problem.
In my website all user have there own mail box which can be seen by them when they log in.
I have not assigned then any ids like 123@gmail.com or anything else.
They can send mails to each-other through their names only.
When they send a mail to diffrent user, it is saved as a data row in the database with the help of personid.
Now i want that if a user sends a mail to one other user, it should also automatically send a notification mail to the receiver’s external mail id.
I found the related code like
MailMessage mail = new MailMessage();
mail.To.Add("hiral@yahoo.com");
mail.From = new MailAddress("hiral@gmail.com");
mail.Subject = "Send Email by asp.net code using google or gmail smtp server";
string Body = "Hi, I am testing Email function in asp.net";
mail.Body = Body;
SmtpClient smtp = new SmtpClient("localhost", 25);
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("hiral@gmail.com", "xxxxxxxxxxxxxx");
//Or your Smtp Email ID and Password
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.EnableSsl = true;
smtp.Send(mail);
lblsuccess.Visible = true;
It is working perfectly for me now..
Now i need to change the send field in
mail.From = new MailAddress("hiral@gmail.com");
Because it can be any user without any email id like this.
What can i do for this..?
Retrieve the person/sender information from database by personid then put it on a variable list.