Sharepoint Email Sending
string UIDName= "test";
MailMessage message = new MailMessage();
message.From = new MailAddress(@"test@test.com");
if (!Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.IsSiteAdmin)
{
message.To.Add(UIDName+ @"@test.com");
}
else
{
//message.To.Add(........Default Email Id..........);
}
message.Subject = "Hello..........This is test Email";
//message.Body = body;
message.Body = "body";
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtphost";
smtp.Port = 25;
smtp.Credentials = (System.Net.NetworkCredential)System.Net.CredentialCache.DefaultCredentials;
try
{
smtp.Send(message);
}
catch (System.Exception ex)
{
System.Diagnostics.Trace.WriteLine("SendEmail: Error while sending email. Message=" + ex.Message.ToString());
}
string UIDName= "test";
MailMessage message = new MailMessage();
message.From = new MailAddress(@"test@test.com");
if (!Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.IsSiteAdmin)
{
message.To.Add(UIDName+ @"@test.com");
}
else
{
//message.To.Add(........Default Email Id..........);
}
message.Subject = "Hello..........This is test Email";
//message.Body = body;
message.Body = "body";
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtphost";
smtp.Port = 25;
smtp.Credentials = (System.Net.NetworkCredential)System.Net.CredentialCache.DefaultCredentials;
try
{
smtp.Send(message);
}
catch (System.Exception ex)
{
System.Diagnostics.Trace.WriteLine("SendEmail: Error while sending email. Message=" + ex.Message.ToString());
}