Thursday, November 3, 2011
Friday, October 28, 2011
DOTNet Sent Mail Coding
protected void SendMail(string FromUserName, string ToUserName, string strContent, string strSubject)
{
try
{
string mstrContents;
//Retrives the contact mail ids
if (FromUserName != null && FromUserName.Trim() != "" && ToUserName != null && ToUserName.Trim() != "")
{
//Retrives the mailing contents
string strSiteName = DefaultSettings.SiteID;//ConfigurationManager.AppSettings["siteId"].ToString().Trim(); ;
SPSite site = new SPSite(strSiteName);
SPWeb web = site.OpenWeb();
string ToEmailid = web.AllUsers[ToUserName].Email;
string FromEmailId = ConfigurationManager.AppSettings["FromEmailId"].ToString().Trim(); ;
SmtpClient objSmtp = new SmtpClient(ConfigurationManager.AppSettings["SMTP"].ToString().Trim());
if (SPUtility.IsEmailServerSet(web))
{
MailAddress from = new MailAddress(FromEmailId);
MailAddress to = new MailAddress(ToEmailid);
MailMessage message = new MailMessage(from, to);
message.Subject = strSubject;
mstrContents = strContent;
message.Body = mstrContents;
objSmtp.Send(message);
}
site.Close();
site.Dispose();
web.Close();
web.Dispose();
}
}
catch (Exception ex)
{
string strError = ex.Message.ToString();
objErrorLog.WriteintoLogFile(ex.Message);
objErrorLog.WriteintoLogFile(ex.StackTrace);
}
}
{
try
{
string mstrContents;
//Retrives the contact mail ids
if (FromUserName != null && FromUserName.Trim() != "" && ToUserName != null && ToUserName.Trim() != "")
{
//Retrives the mailing contents
string strSiteName = DefaultSettings.SiteID;//ConfigurationManager.AppSettings["siteId"].ToString().Trim(); ;
SPSite site = new SPSite(strSiteName);
SPWeb web = site.OpenWeb();
string ToEmailid = web.AllUsers[ToUserName].Email;
string FromEmailId = ConfigurationManager.AppSettings["FromEmailId"].ToString().Trim(); ;
SmtpClient objSmtp = new SmtpClient(ConfigurationManager.AppSettings["SMTP"].ToString().Trim());
if (SPUtility.IsEmailServerSet(web))
{
MailAddress from = new MailAddress(FromEmailId);
MailAddress to = new MailAddress(ToEmailid);
MailMessage message = new MailMessage(from, to);
message.Subject = strSubject;
mstrContents = strContent;
message.Body = mstrContents;
objSmtp.Send(message);
}
site.Close();
site.Dispose();
web.Close();
web.Dispose();
}
}
catch (Exception ex)
{
string strError = ex.Message.ToString();
objErrorLog.WriteintoLogFile(ex.Message);
objErrorLog.WriteintoLogFile(ex.StackTrace);
}
}
.Net SmtpClient e-mail send with attachments coding
public void SendMail(string FromUserName, string ToUserName, string strContent, string strSubject, string strAttachmentPath, bool IsAttachment)
{
try
{
string mstrContents;
//Retrives the contact mail ids
if (FromUserName != null && FromUserName.Trim() != "" && ToUserName != null && ToUserName.Trim() != "")
{
//Retrives the mailing contents
string strSiteName = DefaultSettings.SiteID;//ConfigurationManager.AppSettings["siteId"].ToString().Trim(); ;
SPSite site = new SPSite(strSiteName);
SPWeb web = site.OpenWeb();
string ToEmailid = web.AllUsers[ToUserName].Email;
string FromEmailId = ConfigurationManager.AppSettings["FromEmailId"].ToString().Trim(); ;
SmtpClient objSmtp = new SmtpClient(ConfigurationManager.AppSettings["SMTP"].ToString().Trim());
if (SPUtility.IsEmailServerSet(web))
{
MailAddress from = new MailAddress(FromEmailId);
MailAddress to = new MailAddress(ToEmailid);
MailMessage message = new MailMessage(from, to);
Attachment data = new Attachment(strAttachmentPath, MediaTypeNames.Application.Octet);
// Add time stamp information for the file.
ContentDisposition disposition = data.ContentDisposition;
if(strSubject.Contains("Workflow Status Report"))
{
disposition.FileName = "WorkflowStatusReport.xls";
}
if(strSubject.Contains("Live Agreement Report"))
{
disposition.FileName = "LiveAgreementReport.xls";
}
disposition.CreationDate = System.IO.File.GetCreationTime(strAttachmentPath);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(strAttachmentPath);
disposition.ReadDate = System.IO.File.GetLastAccessTime(strAttachmentPath);
// Add the file attachment to this e-mail message.
message.Attachments.Add(data);
message.Subject = strSubject;
mstrContents = strContent;
message.Body = mstrContents;
objSmtp.Send(message);
data.Dispose();
}
site.Close();
site.Dispose();
web.Close();
web.Dispose();
}
}
catch (Exception ex)
{
string strError = ex.Message.ToString();
objErrorLog.WriteintoLogFile(ex.Message);
objErrorLog.WriteintoLogFile(ex.StackTrace);
}
}
{
try
{
string mstrContents;
//Retrives the contact mail ids
if (FromUserName != null && FromUserName.Trim() != "" && ToUserName != null && ToUserName.Trim() != "")
{
//Retrives the mailing contents
string strSiteName = DefaultSettings.SiteID;//ConfigurationManager.AppSettings["siteId"].ToString().Trim(); ;
SPSite site = new SPSite(strSiteName);
SPWeb web = site.OpenWeb();
string ToEmailid = web.AllUsers[ToUserName].Email;
string FromEmailId = ConfigurationManager.AppSettings["FromEmailId"].ToString().Trim(); ;
SmtpClient objSmtp = new SmtpClient(ConfigurationManager.AppSettings["SMTP"].ToString().Trim());
if (SPUtility.IsEmailServerSet(web))
{
MailAddress from = new MailAddress(FromEmailId);
MailAddress to = new MailAddress(ToEmailid);
MailMessage message = new MailMessage(from, to);
Attachment data = new Attachment(strAttachmentPath, MediaTypeNames.Application.Octet);
// Add time stamp information for the file.
ContentDisposition disposition = data.ContentDisposition;
if(strSubject.Contains("Workflow Status Report"))
{
disposition.FileName = "WorkflowStatusReport.xls";
}
if(strSubject.Contains("Live Agreement Report"))
{
disposition.FileName = "LiveAgreementReport.xls";
}
disposition.CreationDate = System.IO.File.GetCreationTime(strAttachmentPath);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(strAttachmentPath);
disposition.ReadDate = System.IO.File.GetLastAccessTime(strAttachmentPath);
// Add the file attachment to this e-mail message.
message.Attachments.Add(data);
message.Subject = strSubject;
mstrContents = strContent;
message.Body = mstrContents;
objSmtp.Send(message);
data.Dispose();
}
site.Close();
site.Dispose();
web.Close();
web.Dispose();
}
}
catch (Exception ex)
{
string strError = ex.Message.ToString();
objErrorLog.WriteintoLogFile(ex.Message);
objErrorLog.WriteintoLogFile(ex.StackTrace);
}
}
Sharepoint Custom Search Coding
using Microsoft.Office.Server.Administration;
using Microsoft.Office.Server.Search;
using Microsoft.Office.Server.Search.Query;
public DataSet getSearchResults(string strSqlString)
{
DataSet dsResults = null;
string strSiteUrl = ConfigurationManager.AppSettings["siteId"].ToString();
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(strSiteUrl))
{
FullTextSqlQuery query = new FullTextSqlQuery(site);
query.QueryText = strSqlString;
query.RowLimit = 30000;
query.ResultTypes = ResultType.RelevantResults;
ResultTableCollection coll = query.Execute();
if ((int)ResultType.RelevantResults != 0)
{
ResultTable tblResult = coll[ResultType.RelevantResults];
if (tblResult.TotalRows > 0)
{
DataTable dtResults = new DataTable("tblResults");
dsResults = new DataSet();
dsResults.Tables.Add(dtResults);
dsResults.Load(coll[ResultType.RelevantResults], LoadOption.OverwriteChanges, dtResults);
}
}
}
});
}
catch (Exception ex)
{
throw ex;
}
return dsResults;
}
Sharepoint Server 2007 common Errors
You cannot visit any site collection from an Office
SharePoint Server 2007 content database after you attach the content database
to a SharePoint Server 2010 environment
You receive a "Cannot connect to the configuration
database" error message when you connect to your Windows SharePoint Services 2.0 Web site
The User Profile
Synchronization service does not start on a stand-alone installation of
SharePoint Server 2010
SharePoint Draft items not crawled
How to add lots of users to a site, to a list, or to a document
library in Windows SharePoint Services
3.0 and in SharePoint Server 2007
You cannot use the Item Updating event to
retrieve an updated value in SharePoint Server
2007 or in Windows SharePoint Services 3.0
Error message when you try to take an external list offline after
you uninstall and then reinstall SharePoint Server 2010: "Failed to obtain
signing certificate"
You receive a "Service Unavailable" error message when you browse a Windows SharePoint Services
2.0 Web site
How to rename a computer that is running SharePoint Portal Server 2003
How to automate the deletion of backups in SharePoint Server 2007 and
in Windows SharePoint Services 3.0 by using a Visual Basic script
How to defragment Windows SharePoint Services 3.0 databases and SharePoint Server 2007
databases
Using Microsoft Windows SharePoint Services with a content
database that is configured as read-only
in Microsoft SQL Server
Thursday, October 27, 2011
Microsoft Most important Sharepoint Sites
Microsoft Enterprise Search Blog
(Learn about the Enterprise Content Management features in SharePoint and Office 2010 and engage with the people who build and deliver the products)
Microsoft Records Management Team Blog
A blog about the business challenges we are all facing and the opportunities to address these challenges using technology, as we encounter the problems of records keeping, planning, retention, disposition, litigation response, holds, and so on.
Microsoft Project 2010 The official blog of the Microsoft Office product development group. Learn how to manage your work effectively
Performance Point Services
Microsoft SharePoint Developer Documentation Team Blog
GetThePoint
Enterprise Project management Content
Microsoft Business Connectivity Services Team Blog
http://blogs.msdn.com/b/bcs/
Microsoft Records Management Team Blog
http://blogs.msdn.com/b/recman/
Microsoft Dynamics Mobile Team blog
http://blogs.msdn.com/b/dynamicsmobile/
SharePoint Developer Building Blocks: Technologies for Creating SharePoint Applications:
http://blogs.msdn.com/b/ericwhite/archive/2010/10/26/sharepoint-developer-building-blocks-technologies-for-creating-sharepoint-applications.aspx
Office SharePoint Server 2007 Training Resources:
http://blogs.msdn.com/b/sharepointserver2007trainingcanada
Windows SharePoint Services Manageability Controls (Governance Series Part 1 of 5)
http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?PageType=4&ListId={72C1C85B-1D2D-4A4A-90DE-CA74A7808184}&pID=732
SharePoint History
http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?PageType=4&ListId={72C1C85B-1D2D-4A4A-90DE-CA74A7808184}&pID=467
SharePoint Resources:
http://blogs.msdn.com/b/arpans/archive/2004/10/11/241116.aspx
Microsoft Office SharePoint Server 2007
http://blogs.msdn.com/b/arpans/archive/2006/05/30/611165.aspx
SharePoint Thinks, Links and Clinks:
http://blogs.msdn.com/b/tadd/
Sharepointcomic
Microsoft Records Management Team Blog
http://blogs.msdn.com/b/recman/
Microsoft Dynamics Mobile Team blog
http://blogs.msdn.com/b/dynamicsmobile/
SharePoint Developer Building Blocks: Technologies for Creating SharePoint Applications:
http://blogs.msdn.com/b/ericwhite/archive/2010/10/26/sharepoint-developer-building-blocks-technologies-for-creating-sharepoint-applications.aspx
Office SharePoint Server 2007 Training Resources:
http://blogs.msdn.com/b/sharepointserver2007trainingcanada
Windows SharePoint Services Manageability Controls (Governance Series Part 1 of 5)
http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?PageType=4&ListId={72C1C85B-1D2D-4A4A-90DE-CA74A7808184}&pID=732
SharePoint History
http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?PageType=4&ListId={72C1C85B-1D2D-4A4A-90DE-CA74A7808184}&pID=467
SharePoint Resources:
http://blogs.msdn.com/b/arpans/archive/2004/10/11/241116.aspx
Microsoft Office SharePoint Server 2007
http://blogs.msdn.com/b/arpans/archive/2006/05/30/611165.aspx
SharePoint Thinks, Links and Clinks:
http://blogs.msdn.com/b/tadd/
The Microsoft MVP Award Program Blog
SQL Server Mail Configuration
After configuring
SQL Server database mail and testing it successfully, you could find maintenance
plans unable to send e-mails although you have set the recipients correctly.
This is generally
due to the setting for the default profile for database
mail.
Generally, you need
to do the following to configure database mail:
1. In SQL Server Management Studio, select Management, Database
Mail
2. Select Configure Database
Mail
3. On the Database Mail Configuration Wizard,
select setup Database Mail and
configure the SMTP settings
Secondly, you need
to configure the default profile as follows:
1. In SQL Server Management Studio, select Management, Database
Mail
2. Select Configure Database
Mail
3. On the Database Mail Configuration Wizard,
select Manage Profile Security
4. Under Public Profiles, select Yes in the Default Profile to set the default
Profile
Subscribe to:
Posts (Atom)