Thursday, October 20, 2011

Sending mail with image in PowerShell

$smtpServer = "<smtp server name>"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment("<image path>")
$att.ContentDisposition.Inline = $True
$att.ContentDisposition.DispositionType = "Inline"
$att.ContentType.MediaType = "image/jpeg"
$att.ContentId = "logo"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.IsBodyHTML = $True
$msg.From = "<from address>"
$msg.To.Add("<to address>")
$msg.cc.Add("<cc address>")
$msg.Subject = "<mail subject>"
$msg.Attachments.Add($att)
$msg.Body = "<mail body>... <img src='cid:logo'>"
Add-Content -Path "d:\mylog.txt" -Value "Mail Sent..."
$smtp.Send($msg)
$att.Dispose()

Sending mail with attachment in PowerShell

$file = "c:\myfile.text"
$smtpServer = "<smtpservername>"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($file)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "<from address>"
$msg.To.Add("<to address>")
$msg.Subject = "<mail subject>"
$msg.Body = "<mail body>"
$msg.Attachments.Add($att)
$smtp.Send($msg)
$att.Dispose()

Wednesday, October 12, 2011

PowerShell script to send mail

        $headers = New-Object System.Collections.Specialized.StringDictionary
        $headers.Add("to", "test1@abc.com")
        $headers.Add("cc", "test2@abc.com")
        $headers.Add("bcc", "test3@abc.com")
        $headers.Add("from", "test@test.com")
        $headers.Add("subject", "Test Email Subject")
        $headers.Add("content-type", "text/html")
        $bodyText = "Hello how are you?"
        [Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web, $headers, $bodyText)

Friday, October 7, 2011

In Infopath the Conditions in rules are limited to only 5 !!!

You can overcome this by changing your last condition to "The expression" and use "and" or "or" as needed to create your compound condition. So, for example, if you need to make sure both field1 and field2 are not blank, you'd use the expression:



If you need help figuring out the correct syntax for your expression, first set up the condition using the drop downs (for example, select field1 in your first drop down, then "is not blank" in your second drop down), then change the first drop down to "The expression" -- whatever your condition was will auto populate into the box for the expression. Paste that into a text editor, and then do the same for the rest of your conditions. Add and or or between them as needed, and you have your expression!

Thursday, October 6, 2011

How to check the SharePoint Installation Type (Standalone/farm

Here we can easily find out the type of SharePoint Installation on your machine.

1. Open Registry editer
Run>regedit.exe

2. Navigate this path
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS

check the "ServerRole"


There will be an entry for "ServerRole" which type of your installation
SINGLESERVER - Stand Alone
APPLICATION - Farm Complete
WFE - Web Front End

How to launch a document by clicking a link to the file?

Word: <a href='ms-word:ofe|u|path/to/web/word/document.docx'>Link to document</a> Excel: <a href='ms-excel:o...