For send mail in asp.net query.
I don`t want to show email id given in credentials as from id when it comes to inbox, for eg. if [email protected] is used in credentials and in from there is [email protected] i want to show [email protected] as sender when mail comes in inbox

Suraj SahooRank #382 · 6.6K reputationPosted Feb 4, 2015, 10:21 PM EST
You can set the default from address in the webconfig.
somewhat like below:
Suraj SahooRank #382 · 6.6K reputationPosted Feb 4, 2015, 11:29 PM EST
then the web config change mentioned will do the same thing
Suraj SahooRank #382 · 6.6K reputationPosted Feb 5, 2015, 12:50 AM EST
Testdemo Foremail19 reputationPosted Feb 5, 2015, 1:37 AM EST
i have Gmail id and pass....k
i can send mail this id and pass
but when receiver receive mail at time time what we write from email id just display in inbox
this from email id.not credential email id display.
credential is common but from email id is changable...
plz help me..
Suraj SahooRank #382 · 6.6K reputationPosted Feb 5, 2015, 2:13 AM EST
You can use one thing make the from part in the web config dynamic by the below peice of code:
public void saveIdentity(string frommailID)
{
Configuration objConfig = WebConfigurationManager.OpenWebConfiguration("~"); IdentitySection identitySection = (IdentitySection)objConfig.GetSection("system.net/mailSettings/smtp");
if (identitySection != null)
{
identitySection.from= frommailID;
}
objConfig.Save();
}
Please try this. I hope this will work
Thanks
Suraj SahooRank #382 · 6.6K reputationPosted Feb 5, 2015, 3:23 AM EST
Configuration c = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath); MailSettingsSectionGroup settings = (MailSettingsSectionGroup)c.GetSectionGroup("system.net/mailSettings");
you can use this two lines instead of identity
Please try this
Saber ShaikhRank #1,687 · 905 reputationPosted Feb 5, 2015, 8:11 PM EST
http://aspnettutorialscode.blogspot.in/2013/11/aspnet-send-email-using-gmail-or-gmail.html
Testdemo Foremail19 reputationPosted Feb 5, 2015, 8:39 PM EST
I don`t want to show email id given in credentials as from id when it comes to inbox,
for eg. if [email protected] is used in credentials and in from there is [email protected] (this come for database dynamic)
i want to show [email protected] as sender when mail comes in inbox
Saber ShaikhRank #1,687 · 905 reputationPosted Feb 5, 2015, 8:46 PM EST
(A) is Login --- And Send To Mail (B)
Or
(A)is Login -- And Send Mail By (B)
How Can That Posible witch is your Requerment 1 or 2
Testdemo Foremail19 reputationPosted Feb 5, 2015, 8:56 PM EST
NetworkCredential logininfo = new NetworkCredential("[email protected]", "12345679");
SmtpClient msmtpclient = new SmtpClient();
MailMessage msg = new MailMessage();
msg.From = new MailAddress("[email protected]", "jagdishparmar");
msg.To.Add(new MailAddress("[email protected]"));
msg.Subject = "Hello";
msg.Body = "To stop receiving these emails please click here to unsubscribe.";
msg.IsBodyHtml = true;
msmtpclient.Host = "smtp.gmail.com";
msmtpclient.Port = 587;
msmtpclient.EnableSsl = true;
msmtpclient.UseDefaultCredentials = true;
msmtpclient.Credentials = logininfo;
msmtpclient.Send(msg)
Testdemo Foremail19 reputationPosted Feb 5, 2015, 8:57 PM EST
Saber ShaikhRank #1,687 · 905 reputationPosted Feb 5, 2015, 9:07 PM EST
Testdemo Foremail19 reputationPosted Feb 5, 2015, 9:38 PM EST
string from = "[email protected]";//Set Here dt.rows[0][0] with your fild from Database
NetworkCredential NetworkCred = new NetworkCredential(Id,Pass);
when open the inbox and display a mail id at that time display from maiil for inbox mail
Testdemo Foremail19 reputationPosted Feb 5, 2015, 10:04 PM EST