Tuesday, September 8, 2015

SMTP Timeout error–Resolution.

 

at System.Net.Mail.SmtpClient.Send(MailMessage message)

 

public static bool SendLongProcessEmail(string smtpserver, MailMessage newEmail, SmtpClient client)
        {
            Log logmsg = new Log();
            bool mailSent = false;
            try
            {
             
                try
                {

                    client.Host = smtpserver;
                    client.ServicePoint.MaxIdleTime = 0;
                    client.ServicePoint.ConnectionLimit = 1;
                    client.Timeout = 10000000;
                    client.Send(newEmail);
                    mailSent = true;

                }
                catch (Exception)
                {
                    client.Send(newEmail);
                    mailSent = true;
                }
            }
            catch (Exception ex)
            {
                logmsg.HandleException(ex.StackTrace, ex.Message, "SendLongProcessEmail Method");
                return false;
            }
            return mailSent;
        }

Technorati Tags: ,,,,

Saturday, August 29, 2015

Sending email from PowerShell

 

Send-MailMessage –From Guruprasad_Marathe@aaa.com –To Guruprasad_Marathe@aaa.com –Subject “Test Email” –Body “Test E-mail (body)” -SmtpServer mailserver.amat.com

 

Technorati Tags: ,,

PowerShell to unlock the files which are locked from SharePoint

 

 

$web = Get-SPWeb http://<site>/Ringo

$list = $web.Lists["Shared Documents"]

$item = $list.GetItemById(171)

$file = $item.File

$file

$userId = $file.LockedByUser.ID

$user = $web.AllUsers.GetByID($userId)

$impSite= New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken);

$impWeb = $impSite.OpenWeb();

$impList = $impWeb.Lists[$list.Title]

$impItem = $impList.GetItemById($item.ID)

$impFile = $impItem.File

$impFile.ReleaseLock($impFile.LockId)