fredag den 14. august 2009

Send mail i PowerShell

#####################################
function SendMail([string]$TextToSend)
{
$filename = "filename.txt"
$smtpServer = "SmtpServerName"

$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($filename)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

[string]$tempFrom = $env:computername + ' <' + $env:computername + "@" + $env:userdomain + ".COM>"
$tempFrom $msg.From = $tempFrom
$msg.To.Add("sendto@domain.com")
$msg.Subject = "Subject"
$msg.Body = $TextToSend$msg.Attachments.Add($att)

$smtp.Send($msg)
$msg.dispose()
}
#####################################

onsdag den 5. august 2009

Sharepoint 2010 Links

Redirect SharePoint Site to New Location

1. Add a Content Editor Web Part to the Main Page of the site.
2. Modify the Web Part and click on Source Editor.
3. Paste in the following code while changing the URLs to match your target.

<HTML>
<HEAD>
<SCRIPT language="JavaScript">
<!--
function redirectsp()
{
top.location="http://sharepoint";
}
if (top.frames.length==0)
{
setTimeout('redirectsp()',0);
}
//-->
</SCRIPT>
</HEAD>
<body>
Redirecting you to the new location. If you are not redirected, click <a href="http://sharepoint">HERE.</a>
</body>
</html>

4. I set the redirect time to 0, but you can set it higher if you like. 1 sec = 1000, 2 sec = 2000, etc.
5. Save the code changes.

The fun part of this solution is the fact that the code tries to load no matter what view you are in (i.e. Standard view, Edit Page, etc). So, if you have to make changes to the code you have to let the page load but then time a press of the ESC key to keep the Javascript from loading each
time.