<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>devtrends.com &#187; Visual Studio</title>
	<atom:link href="http://www.devtrends.com/index.php/category/software-development/visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devtrends.com</link>
	<description>developing trends in information technology</description>
	<lastBuildDate>Tue, 06 Sep 2011 19:27:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Remove DigiNotar Certificate with VB.NET</title>
		<link>http://www.devtrends.com/index.php/remove-diginotar-certificate-with-vb-net/</link>
		<comments>http://www.devtrends.com/index.php/remove-diginotar-certificate-with-vb-net/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 15:34:10 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Certificate]]></category>
		<category><![CDATA[DigiNotar]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[X509]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=743</guid>
		<description><![CDATA[As I am sure you are aware, there is at least one fraudulent digital certificate released by DigiNotar that is causing security concerns with domains associated with google.com. With Windows...]]></description>
			<content:encoded><![CDATA[<p>As I am sure you are aware, there is at least one fraudulent digital certificate released by DigiNotar that is causing security concerns with domains associated with google.com. With Windows Vista/ 7/2008, certificates are checked using the Certificate Trust List built in to the operating system. For Windows XP/2003, users are not as lucky. Either way, it may be a good idea to remove the certificate from your store. Manually, this is easy; load up mmc. If you need to accomplish this on many machines, one method would be the example below.</p>
<p><a href="http://www.microsoft.com/technet/security/advisory/2607712.mspx" target="_new">http://www.microsoft.com/technet/security/advisory/2607712.mspx</a></p>
<p>Before you continue with creating your own solution to removign DigiNotar, review this recent update from Microsoft for an out-of-band update: <a href="http://support.microsoft.com/kb/2607712" target="_new">http://support.microsoft.com/kb/2607712</a>.</p>
<p>The code below will remove certificates containing the word “DigiNotar” in the SubjectName field. The code iterates all certificates in the following stores, in this order, using nearly identical blocks of code:</p>
<ol>
<li>REMOVES *DigiNotar* in the Intermediate certificates store for Current User</li>
<li>REMOVES *DigiNotar*in the Intermediate certificates store on Local Machine</li>
<li>REMOVES *DigiNotar*in the Trusted &#8220;Root&#8221; certificate store for Current User</li>
<li>REMOVES *DigiNotar*in the Trusted &#8220;Root&#8221; certificate store on Local Machine</li>
</ol>
<p>The code removes certificates from both the current user and local machine. Obviously, the local machine will require administrative permissions and the current user will need to be ran on every user. For deployment, you would need to run for each user in their context on every system and once for each system for the root certificate. If you are only concerned with the root certificate, then remove the blocks of code that reference current user.</p>
<p><strong>As with all of my blog articles, there is no warranty or guarantee from the sample provided below. The security of your environment is your responsibility. If the code does not work or causes other issues in your environment, it is your responsibility. You should thorough test prior to release to a production environment.</strong></p>
<p>Removing DigiNotar certificates .NET Framework 2.0 code example:</p>
<blockquote><p>Imports System<br />
Imports System.Security.Cryptography<br />
Imports System.Security.Cryptography.X509Certificates<br />
Imports System.IO</p>
<p>Module Module1<br />
Dim certsRemoved As Boolean = False<br />
Dim myExitCode As Integer = 0<br />
&#8216;exit code table<br />
&#8217;0 = cert removed<br />
&#8217;1 = nothing removed<br />
&#8217;2 = error</p>
<p>Sub Main()<br />
Console.WriteLine(&#8220;devtrends.com &#8212; September 2, 2011&#8243;)<br />
Console.WriteLine(&#8220;Removes DigiNotar* from the Root and CertificateAuthority (Intermediate) certificate store.&#8221;)<br />
Console.WriteLine(&#8220;&#8221;)</p>
<p>&#8217;1. REMOVES DigiNotar in the Intermediate certificates store for Current User<br />
Try<br />
&#8216;open a connection to the X509 local certificate store.<br />
Dim store As X509Store = New X509Store(X509Certificates.StoreName.CertificateAuthority, StoreLocation.CurrentUser)<br />
store.Open(OpenFlags.ReadWrite)</p>
<p>&#8216;loop through and find the cert we want to work with<br />
For Each cert As X509Certificate2 In store.Certificates<br />
&#8216;Console.WriteLine(cert.SubjectName.Name)<br />
If (cert.SubjectName.Name.Contains(&#8220;DigiNotar&#8221;)) Then<br />
Console.WriteLine(&#8220;User Intermediate Removed: &#8221; &amp; cert.SubjectName.Name)<br />
store.Remove(cert)<br />
certsRemoved = True<br />
End If<br />
Next</p>
<p>&#8216;close the store object<br />
store.Close()</p>
<p>&#8216;did we remove anything?<br />
If certsRemoved Then<br />
myExitCode = 0<br />
Else<br />
myExitCode = 1<br />
Console.WriteLine(&#8220;User Intermediate: DigiNotar not found. Nothing removed.&#8221;)<br />
End If<br />
Catch ex As Exception<br />
Console.WriteLine(&#8220;User Intermediate Error: &#8221; &amp; ex.Message)<br />
myExitCode = 2<br />
End Try</p>
<p>&#8217;2. REMOVES DigiNotar in the Intermediate certificates store on Local Machine<br />
Try<br />
&#8216;open a connection to the X509 local certificate store.<br />
Dim store As X509Store = New X509Store(X509Certificates.StoreName.CertificateAuthority, StoreLocation.LocalMachine)<br />
store.Open(OpenFlags.ReadWrite)</p>
<p>&#8216;loop through and find the cert we want to work with<br />
For Each cert As X509Certificate2 In store.Certificates<br />
&#8216;Console.WriteLine(cert.SubjectName.Name)<br />
If (cert.SubjectName.Name.Contains(&#8220;DigiNotar&#8221;)) Then<br />
Console.WriteLine(&#8220;Local Machine Intermediate Removed: &#8221; &amp; cert.SubjectName.Name)<br />
store.Remove(cert)<br />
certsRemoved = True<br />
End If<br />
Next</p>
<p>&#8216;close the store object<br />
store.Close()</p>
<p>&#8216;did we remove anything?<br />
If certsRemoved Then<br />
myExitCode = 0<br />
Else<br />
myExitCode = 1<br />
Console.WriteLine(&#8220;Local Machine Intermediate: DigiNotar not found. Nothing removed.&#8221;)<br />
End If<br />
Catch ex As Exception<br />
Console.WriteLine(&#8220;Local Machine Intermediate Error: &#8221; &amp; ex.Message)<br />
myExitCode = 2<br />
End Try</p>
<p>&#8217;3. REMOVES DigiNotar in the Trusted &#8220;Root&#8221; certificate store for Current User<br />
Try<br />
&#8216;open a connection to the X509 local certificate store.<br />
Dim store As X509Store = New X509Store(X509Certificates.StoreName.Root, StoreLocation.CurrentUser)<br />
store.Open(OpenFlags.ReadWrite)</p>
<p>&#8216;loop through and find the cert we want to work with<br />
For Each cert As X509Certificate2 In store.Certificates<br />
If (cert.SubjectName.Name.Contains(&#8220;DigiNotar&#8221;)) Then<br />
Console.WriteLine(&#8220;User Root Removed: &#8221; &amp; cert.SubjectName.Name)<br />
store.Remove(cert)<br />
certsRemoved = True<br />
End If<br />
Next<br />
&#8216;close the store object</p>
<p>store.Close()<br />
&#8216;did we remove anything?<br />
If certsRemoved Then<br />
myExitCode = 0<br />
Else<br />
myExitCode = 1<br />
Console.WriteLine(&#8220;User Root: DigiNotar not found. Nothing removed.&#8221;)<br />
End If<br />
Catch ex As Exception<br />
Console.WriteLine(&#8220;User Root Error: &#8221; &amp; ex.Message)<br />
myExitCode = 2<br />
End Try</p>
<p>&#8217;4. REMOVES DigiNotar in the Trusted &#8220;Root&#8221; certificate store on Local Machine<br />
Try<br />
&#8216;open a connection to the X509 local certificate store.<br />
Dim store As X509Store = New X509Store(X509Certificates.StoreName.Root, StoreLocation.LocalMachine)<br />
store.Open(OpenFlags.ReadWrite)</p>
<p>&#8216;loop through and find the cert we want to work with<br />
For Each cert As X509Certificate2 In store.Certificates<br />
If (cert.SubjectName.Name.Contains(&#8220;DigiNotar&#8221;)) Then<br />
Console.WriteLine(&#8220;Local Machine Root Removed: &#8221; &amp; cert.SubjectName.Name)<br />
store.Remove(cert)<br />
certsRemoved = True<br />
End If<br />
Next</p>
<p>&#8216;close the store object<br />
store.Close()</p>
<p>&#8216;did we remove anything?<br />
If certsRemoved Then<br />
myExitCode = 0<br />
Else<br />
myExitCode = 1<br />
Console.WriteLine(&#8220;Local Machine Root: DigiNotar not found. Nothing removed.&#8221;)<br />
End If<br />
Catch ex As Exception<br />
Console.WriteLine(&#8220;Local Machine Root Error: &#8221; &amp; ex.Message)<br />
myExitCode = 2<br />
End Try</p>
<p>&#8216;exit with specific exit code<br />
Console.WriteLine(&#8220;&#8221;)<br />
Console.WriteLine(&#8220;Exit code: (&#8221; &amp; myExitCode &amp; &#8220;)&#8221;)<br />
Environment.Exit(myExitCode)<br />
End Sub</p>
<p>End Module</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/remove-diginotar-certificate-with-vb-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Centralized Desktop and Favorites with a Centralized My Documents?</title>
		<link>http://www.devtrends.com/index.php/centralized-desktop-and-favorites-with-a-centralized-my-documents/</link>
		<comments>http://www.devtrends.com/index.php/centralized-desktop-and-favorites-with-a-centralized-my-documents/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 02:25:37 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[centralized desktop]]></category>
		<category><![CDATA[centralized favorites]]></category>
		<category><![CDATA[migrate desktop]]></category>
		<category><![CDATA[migrate favorites]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=592</guid>
		<description><![CDATA[What about Desktop and Favorites migration? Wouldn’t it be nice if there was a GPO that made the migration of your user’s Desktop and Favorites as easy as the migration...]]></description>
			<content:encoded><![CDATA[<p>What about Desktop and Favorites migration? Wouldn’t it be nice if there was a GPO that made the migration of your user’s Desktop and Favorites as easy as the migration of their My Documents? I think it would be nice. Since there isn’t, I created a script that would do the migration. This script should be run following a successful My Documents migration as the goal would be to put the files in the same location as the My Documents files.</p>
<p>When I first started the project, I was hoping that my script would run prior to showing the desktop. This is important because if it runs while the user has access to the desktop, that user may start using files that would prevent the script from running correctly (file locks). I had no luck; if anyone has an idea on how to do this, let me know. Otherwise, I created a .NET application that covers the entire screen on the primary monitor (if more than 1 monitor, then the second one is still visible).</p>
<p><strong>BlankScreen</strong></p>
<p>The BlankScreen application is written in VisualStudio .NET 2008 using .NET Framework 2.0 if I remember correctly. There are some changes you may want to make on this application to tailor it for your environment. The first change would be to put your logo on the application form. The second change, and really the more important change, is to change the ProcessPath variable to point to the UNC path of where you plan on putting the desktop.vbs file. This application just runs the VBScript.</p>
<p><a href="http://www.devtrends.com/wp-content/uploads/2010/07/BlankScreen.jpg"><img class="alignnone size-medium wp-image-593" title="BlankScreen" src="http://www.devtrends.com/wp-content/uploads/2010/07/BlankScreen-300x236.jpg" alt="" width="300" height="236" /></a></p>
<p>So you might be thinking, why would you have an application that is capable of much more advanced programming run a VBScript? Well, I wrote the script first and didn’t feel like porting it to VB.NET. If you feel like spending the time, go for it.</p>
<p><strong>desktop.vbs</strong></p>
<p>Enough chatter about the other stuff, on to the real product of this blog post, the VBScript.</p>
<p>The VBScript has four basic functions that it completes one after the other based on the success of the previous function. Step 1 is to get the username of the logged in user. Step 2 is to create the folders in the user’s My Documents location and copy the files into that new folders (nothing is moved). Step 3 is to update the registry for the Desktop and Favorites locations to the newly created folders. Step 4 renames the old folders in the C:\Documents and Settings\[user]\ folder to DesktopOLD and FavoritesOLD. I feared losing user files, so I did not make the script perform anything that couldn’t be reversed.</p>
<p>Just as you had to change a string variable in the BlankScreen application for your specific server, you also have to change the location of your user’s folder on the network. In my case it was \\fileserver\users\.</p>
<p><a href="http://www.devtrends.com/wp-content/uploads/2010/07/desktop_vbs.jpg"><img class="alignnone size-medium wp-image-594" title="desktop_vbs" src="http://www.devtrends.com/wp-content/uploads/2010/07/desktop_vbs-300x257.jpg" alt="" width="300" height="257" /></a></p>
<p>The migration will change the registry keys:</p>
<pre>HKCR\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, Favorites
HKCR\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, Desktop
HKCR\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, Favorites
HKCR\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, Desktop</pre>
<p>The new locations will look something like this:</p>
<p>Desktop: \\[server]\[share]\[username]\Desktop-[username]<br />
Favorites: \\[server]\[share]\[username]\Favorites-[username]<br />
e.g. \\fileserver\users\aaron\Desktop-aaron\ would be my desktop folder.</p>
<p><strong>Conclusion</strong></p>
<p>Implementing this solution is fairly easy. First modify the VB.NET application and compile it. Place the .exe file in a shared location that your login script for users has permissions. Place the VBScript file in a similar location, as you specified in the VB.NET application, and modify the serverpath variable and email variables. Test with your user account in your login script batch file using something similar to below:</p>
<pre>if %USERNAME% == yourusername (
 rem lets make sure the user has a my documents folder prior to trying to migrate their desktop
 if exist "\\[server]\Users\%USERNAME%" (
  if exist "C:\Documents and Settings\%USERNAME%\Desktop" (
   rem lets make sure they have the 2.0 Framework installed.
   if exist "C:\Windows\Microsoft.Net\Framework\v2.0*" (
    start "Desktop Migration" "\\[server]\[share]\blankscreen.exe"
   )
  )
 )
)</pre>
<p>As a disclaimer, the application AND script are provided without any warranty and is only for educational / informational purposes. If you choose to use it in your environment, production or not, the outcome is your responsibility.</p>
<p><strong>desktop.vbs Code</strong></p>
<pre>On Error Resume Next

'alert user of what is happening...
MsgBox "Please click OK to begin the backup process for your Desktop and Internet Explorer Favorites.  This process could take a few minutes, please be patient and Do NOT Cancel anything, otherwise data could be lost!" &amp; vbCrLf &amp; vbCrLf &amp; "If you have Administrator privileges, your computer will restart after all of your files have been copied!"

'get the current user
user = getUser()
'set the server location, the following \ is required!
serverpath = "\\[server]\Users\"
'if you have a helpdesk solution with email capability:
useemailnotify = 0
smtpfrom = "email@domain.com"
smtpto = "email@domain.com"
smtpserver = "smtp.domain.com"

'create folders
m_cf = createFolderscopyFiles(user)
If m_cf &lt;&gt; 1 Then
	'update the registry and reboot
	m_ur = updateRegistry(user)
	If m_ur &lt;&gt; 1 Then
		'rename the old folders so it does not use them anymore!
		m_rof = renameOldFolders(user)
		'reboot
		Set WSHShell = WScript.CreateObject("WScript.Shell")
		WshShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"
	End If
End If

Function getUser()
	'get the current user environment variable.
	Set oShell = CreateObject( "WScript.Shell" )
	user = oShell.ExpandEnvironmentStrings("%UserName%")

	If Err.Number &lt;&gt; 0 Then
		'we have failure!
		getUser = 1
		Err.Clear
	Else
		getUser = user
	End If
End Function

Function createFolderscopyFiles(user)
	Set objFSO = CreateObject("Scripting.FileSystemObject")

	'lets only do the folder create and file copy if that folder doesn't already exist. Otherwise, its just gonna set the registry and reboot.
	If Not objFSO.FolderExists(serverpath &amp; user &amp; "\Desktop-" &amp; user) Then
		'Create the new Desktop and the Favorites folder.
		objFSO.CreateFolder(serverpath &amp; user &amp; "\Desktop-" &amp; user)
		objFSO.CreateFolder(serverpath &amp; user &amp; "\Favorites-" &amp; user)

		Set oSHApp = CreateObject("Shell.Application")

		'Copy the Desktop files
		Set fromDFolder = oSHApp.Namespace("C:\Documents and Settings\" &amp; user &amp; "\Desktop")
		Set toDFolder = oSHApp.Namespace(serverpath &amp; user &amp; "\Desktop-" &amp; user)
		toDFolder.CopyHere fromDFolder.Items, 16+512

		'Copy the Favorites files
		Set fromFFolder = oSHApp.Namespace("C:\Documents and Settings\" &amp; user &amp; "\Favorites")
		Set toFFolder = oSHApp.Namespace(serverpath &amp; user &amp; "\Favorites-" &amp; user)
		toFFolder.CopyHere fromFFolder.Items, 16+512
	End If

	If Err.Number &lt;&gt; 0 Then
		'we have failure!
		SendEmail user,"failed at createFolderscopyFiles",Err.Description
		createFolderscopyFiles = 1
		Err.Clear
	Else
		createFolderscopyFiles = 0
	End If
End Function

Function updateRegistry(user)
	'lets work on the registry now
	Const HKEY_CURRENT_USER = &amp;H80000001
	Const HKEY_LOCAL_MACHINE = &amp;H80000002

	'update the registry for Desktop and Favorites (User Shell Folders)
	'set Favorites
	Set oFReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; "." &amp; "\root\default:StdRegProv")
	strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
	strValueName = "Favorites"
	strValue = serverpath &amp; user &amp; "\Favorites-" &amp; user
	oFReg.SetExpandedStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
	'set Desktop
	Set oDReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; "." &amp; "\root\default:StdRegProv")
	strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
	strValueName = "Desktop"
	strValue = serverpath &amp; user &amp; "\Desktop-" &amp; user
	oDReg.SetExpandedStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue

	'update the registry for Desktop and Favorites (Shell Folders)
	'set Favorites
	Set otFReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; "." &amp; "\root\default:StdRegProv")
	strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
	strValueName = "Favorites"
	strValue = serverpath &amp; user &amp; "\Favorites-" &amp; user
	otFReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
	'set Desktop
	Set otDReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; "." &amp; "\root\default:StdRegProv")
	strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
	strValueName = "Desktop"
	strValue = serverpath &amp; user &amp; "\Desktop-" &amp; user
	otDReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue

	If Err.Number &lt;&gt; 0 Then
		'we have failure!
		SendEmail user,"failed at updating registry",Err.Description
		updateRegistry = 1
		Err.Clear
	Else
		updateRegistry = 0
	End If
End Function

Function renameOldFolders(user)
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	objFSO.MoveFolder "C:\Documents and Settings\" &amp; user &amp; "\Desktop", "C:\Documents and Settings\" &amp; user &amp; "\DesktopOLD"
	objFSO.MoveFolder "C:\Documents and Settings\" &amp; user &amp; "\Favorites", "C:\Documents and Settings\" &amp; user &amp; "\FavoritesOLD"

	If Err.Number &lt;&gt; 0 Then
		'we have failure!
		SendEmail user,"failed at renaming old folders",Err.Description
		renameOldFolders = 1
		Err.Clear
	Else
		renameOldFolders = 0
	End If
End Function

Sub SendEmail(user,contnt,contntB)
	'if the setting is to send an email, then do it, otherwise...nada.
	If useemailnotify = 1 Then
		'send an email!!
		Set objEmail = CreateObject("CDO.Message")
		objEmail.From = smtpfrom
		objEmail.To = smtpto
		objEmail.Subject = "Desktop and Favorites Migration Issue for " &amp; user
		objEmail.Textbody = "User had a Desktop files migration error." &amp; vbCrLf &amp; vbCrLf &amp; contnt &amp; vbCrLf &amp; vbCrLf &amp; contntB
		objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
		objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
		objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
		objEmail.Configuration.Fields.Update
		objEmail.Send

		If Err.Number &lt;&gt; 0 Then
			'we have failure!
			MsgBox "Your Desktop migration didn't go very well."
			Err.Clear
		Else
			'YAY!
		End If
	End If
End Sub
</pre>
<p><strong>Downloads</strong></p>
<p><a href="http://www.devtrends.com/downloads/BlankScreen.zip" target="_self">BlankScreen.zip</a> &#8211; VB.NET application</p>
<p><a href="http://www.devtrends.com/downloads/desktop.zip" target="_self">desktop.zip</a> &#8211; VBScript</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/centralized-desktop-and-favorites-with-a-centralized-my-documents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Startup Notification</title>
		<link>http://www.devtrends.com/index.php/startup-notification/</link>
		<comments>http://www.devtrends.com/index.php/startup-notification/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 21:16:01 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Workstation Management]]></category>
		<category><![CDATA[GPO]]></category>
		<category><![CDATA[Startup]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=500</guid>
		<description><![CDATA[How do you know when an approved and domain-joined workstation is turned on prior to someone even signing into the workstation? Or maybe, you are asking, why would I even...]]></description>
			<content:encoded><![CDATA[<p>How do you know when an approved and domain-joined workstation is turned on prior to someone even signing into the workstation? Or maybe, you are asking, why would I even want to know this? For those that work with network vulnerabilities scanning, such as the product by McAfee’s Foundstone division, this may be of importance. Imagine this scenario. Holiday season arises, everyone loves to take time off and you have an employee that took 2-3 weeks off. When that employee returns, there is a good chance that their computer will be out-dated. From a security standpoint, this is minimal, as it would likely begin receiving updates immediately following a successful sign-on. However, from a political standpoint, if Foundstone is used as a means of judging overall “security”, this workstation could significantly lower that score.</p>
<p>I already know what you are thinking…however, that does not eliminate the fact that dashboard reports are favored by CIOs, IT Directors and the like. Better have that score up to 100%!</p>
<p><strong>StartupNotification</strong></p>
<p>I wrote an application, StartupNotification, that helps with maintaining good scores. Keep in mind that this application only provides a means for notifying the appropriate personnel when a workstation is brought on the network that could potentially “damage”. Second, for this application to be effective in notifying, it must be added as a domain GPO or local policy startup script.</p>
<p><span style="text-decoration: underline;">How It Works</span></p>
<p>Ran from a Windows computer startup script, StartupNotification checks a SQL database for previous records associated with the name of the workstation running StartupNotification. If no records exist, it reports an “Untracked” workstation; if record(s) exist and the latest record is (x) days old, it reports a “Tracked” workstation. After checking the status of the workstation, StartupNotification will create a new record with the workstation name and date of transaction, which will be used at the next StartupNotification check in.</p>
<p><span style="text-decoration: underline;">The Application</span></p>
<p>Download <a href="http://www.devtrends.com/wp-content/uploads/2010/01/StartupNotification.zip">source code</a> (written in Visual Studio 2008).</p>
<p>If you are interested in this application working in your environment, then there are a few things your must do…</p>
<ol>
<li>Create a SQL table with the necessary fields.</li>
<li>Update the application code with your connection string for the database.</li>
<li>Update the email notification messages.</li>
<li>Update the SMTP “from” email address.</li>
</ol>
<p>This is simple, I’ll help you along the way if you follow the steps below carefully:</p>
<p><em>SQL Database and Table</em></p>
<p>I use Microsoft SQL Server 2005; however, this could be easily ported to MySQL, another SQL database, or even a Microsoft Access database. I created a separate database named STARTUPNOTIFICATION for the purpose of holding the table. The table layout is simple, as shown below:</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="213" valign="top">field name</td>
<td width="213" valign="top">data type</td>
<td width="213" valign="top">specifics</td>
</tr>
<tr>
<td width="213" valign="top"><strong>ID</strong></td>
<td width="213" valign="top"><strong>int</strong></td>
<td width="213" valign="top"><strong>primary key, no NULL</strong></td>
</tr>
<tr>
<td width="213" valign="top"><strong>Workstation</strong></td>
<td width="213" valign="top"><strong>nvarchar(50)</strong></td>
<td width="213" valign="top"><strong>NULL</strong></td>
</tr>
<tr>
<td width="213" valign="top"><strong>Date</strong></td>
<td width="213" valign="top"><strong>datetime</strong></td>
<td width="213" valign="top"><strong>no NULL</strong></td>
</tr>
<tr>
<td width="213" valign="top"><strong>IPaddress</strong></td>
<td width="213" valign="top"><strong>nvarchar(50)</strong></td>
<td width="213" valign="top"><strong>NULL</strong></td>
</tr>
</tbody>
</table>
<p><a href="http://www.devtrends.com/wp-content/uploads/2010/01/createtable.zip">createscript.sql</a></p>
<p>You must have a SQL user account that can SELECT and INSERT to this table. It is recommended that this account be a separate account and not the “sa” account or some other powerful, generic account.</p>
<p><em>Update Connection String</em></p>
<p>Locate the “mySQL.ConnectionString” property in the code, as shown the screen shot below, and update the string to match your server and database.</p>
<p><a href="http://www.devtrends.com/wp-content/uploads/2010/01/connectionstring.jpg"><img class="alignnone size-medium wp-image-501" title="connectionstring" src="http://www.devtrends.com/wp-content/uploads/2010/01/connectionstring-300x70.jpg" alt="connectionstring" width="300" height="70" /></a></p>
<p><em>Update Email Notification Messages</em></p>
<p>Locate the “sendEmail” function calls, as shown in the screen shot below, and update the strings to display the text you want to be included in the email. As an example, I have another application I wrote that grabs information on the workstation and user at sign-in; I place a link to display who has signed in to that workstation in the email for quick identification of the workstation location.</p>
<p><a href="http://www.devtrends.com/wp-content/uploads/2010/01/emailnotifications.jpg"><img class="alignnone size-medium wp-image-502" title="emailnotifications" src="http://www.devtrends.com/wp-content/uploads/2010/01/emailnotifications-300x132.jpg" alt="emailnotifications" width="300" height="132" /></a></p>
<p><em>Update SMTP “From” Address</em></p>
<p>The final line that needs your attention is the email address that is used as the sender for this application. In most cases you should use a “do not reply” type email address. Locate the sendEmail function near the bottom of the code and modify the msg.From property line, as shown the screen shot below.</p>
<p><a href="http://www.devtrends.com/wp-content/uploads/2010/01/smtpfromaddress.jpg"><img class="alignnone size-medium wp-image-503" title="smtpfromaddress" src="http://www.devtrends.com/wp-content/uploads/2010/01/smtpfromaddress-300x119.jpg" alt="smtpfromaddress" width="300" height="119" /></a></p>
<p>That is all, compile and set to run as in a startup script. For GPO startup scripts, the application could reside in the NETLOGON path as permissions have not been granted by a signed in user.</p>
<p>Aaron Gilbert</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/startup-notification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Custom Web Browser</title>
		<link>http://www.devtrends.com/index.php/creating-a-custom-web-browser/</link>
		<comments>http://www.devtrends.com/index.php/creating-a-custom-web-browser/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 03:16:08 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Kiosk]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=175</guid>
		<description><![CDATA[As per corporate requirements, I had to create a Kiosk that would allow visitors in the front lobby access to a specific careers and job application web site. Obviously, the...]]></description>
			<content:encoded><![CDATA[<p>As per corporate requirements, I had to create a Kiosk that would allow visitors in the front lobby access to a specific careers and job application web site. Obviously, the computer had to be locked down and &#8220;frozen&#8221;, which was accomplished with Windows SteadyState (see my <a href="http://www.devtrends.com/index.php/using-microsoft-steadystate-for-a-kiosk/" target="_self">article</a>), I also had to make sure that the users could always reach the careers and job application web site without any distractions. Lastly, I had to make a custom screensaver that would fade the screen 50% during a certain time period and 100% the remainder. This was all accomplished by creating a simple .NET Windows application with a web browser object, a few timers and a couple of forms.</p>
<p>And yes, the &#8220;screensaver&#8221; fade was included in the custom web browser as well. See my article on <a href="http://www.devtrends.com/index.php/steadystate-and-screensavers/" target="_self">SteadyState and Screensavers</a> for more information on why I decided to do it that way.</p>
<p>Although the custom web browser was written in Visual Studio .NET 2005 Professional, anyone with a Windows XP + computer could download the free Microsoft Visual Studio 2008 Express  products, such as VB.NET and create the .NET application described below.</p>
<p><strong>New .NET Windows Application</strong></p>
<p>Start out by creating a new .NET Windows Application in the language of your choice. For this example, I will use Visual Basic.</p>
<p>~</p>
<p><em><span style="text-decoration: underline;">frmMain :: the Main Form</span></em><em><span style="text-decoration: underline;"><br />
</span></em></p>
<p>1. First we will modify the form, setting FormBorderStyle to None and setting WindowState to Maximized to fill the entire screen with no border.</p>
<p>2. Next lets drag a ToolStrip on the form, this will be used for navigation.</p>
<p><img class="size-full wp-image-191 alignnone" title="ToolStrip" src="http://www.developingtrends.net/wp-content/uploads/2009/08/ToolStrip.jpg" alt="ToolStrip" width="380" height="174" /></p>
<p>3. While you are dragging the ToolStrip object, drag two (2) Timer objects &#8211; we will use these later on.</p>
<p>4. Modify Timer1 to tick at 1000 millisecond intervals and Timer2 to tick at 180000 (3 minutes) intervals. Timer1 should be enabled and Timer2 disabled.</p>
<p>5. Now lets drag a WebBrowser component on to the form, this will be used for &#8230; well web browsing?</p>
<p>6. For minimal control, add just three buttons to the ToolStrip for controlling the WebBrowser: (1) Back; (2) Refresh; and (3) Back to devtrends.com. To make the buttons better looking than just text or the standard image, I&#8217;ve created custom bitmaps.</p>
<p>Modify the buttons, DisplayStyle to ImageAndText and Text to the text of the button.</p>
<p><img class="alignnone size-full wp-image-192" title="buttons" src="http://www.developingtrends.net/wp-content/uploads/2009/08/buttons.jpg" alt="buttons" width="496" height="106" /></p>
<p>On to the code&#8230;</p>
<p>1. Lets start by modifying the button actions, so double click on the Back button. Use the following code:</p>
<pre style="padding-left: 30px;">'tell the web browser to go back.
If WebBrowser1.CanGoBack = True Then
  WebBrowser1.GoBack()
End If</pre>
<p>2. Refresh button:</p>
<pre style="padding-left: 30px;">'tell the web browser to refresh the page
WebBrowser1.Refresh()</pre>
<p>3. back to devtrends.com button:</p>
<pre style="padding-left: 30px;">'tell the web browser to go to devtrends.com
WebBrowser1.Navigate("http://www.devtrends.com/")</pre>
<p>4. Now lets modify the Load statement to contain the same code as the back to devtrends.com button. This way our web page loads first everytime.</p>
<p>5. Lets make sure the user cannot close the form/application by adding the following code to the FormClosing event for the form:</p>
<pre style="padding-left: 30px;">'prevent user from closing the application
If e.CloseReason = CloseReason.UserClosing Then
  e.Cancel = True
End If</pre>
<p>6. Back at the top of the code, add the following variable statements:</p>
<pre style="padding-left: 30px;">Public mousex As Integer
Public mousey As Integer</pre>
<p>7. In the Form Load statement, add the following statements:</p>
<pre style="padding-left: 30px;">mousex = MousePosition.X
mousey = MousePosition.Y</pre>
<p>8. In Timer1 tick (double click on the Timer1 object in design view), add the following statements:</p>
<pre style="padding-left: 30px;">If mousex &lt;&gt; MousePosition.X Or mousey &lt;&gt; MousePosition.Y Then
  Timer2.Enabled = False
Else
  'the mouse has not moved... start Timer2
  Timer2.Enabled = True
End If

'set current mouse position.
mousex = MousePosition.X
mousey = MousePosition.Y</pre>
<p>9. In Timer2 tick, add the following statements:</p>
<pre style="padding-left: 30px;">Dim fadeform As New frmFader
fadeform.Show()</pre>
<p>~</p>
<p><em><span style="text-decoration: underline;">subMain :: &#8220;sub main&#8221; Module</span></em></p>
<p>This may be an old school method, however, we&#8217;ll create a module that contains a Sub main. Sub main will be the starting point for your application, which we will modify as the last step in this section.</p>
<p>Right click on your project and choose Add &gt; Module, and name the module subMain.</p>
<p>1. Add the following code to your newly created module:</p>
<pre style="padding-left: 30px;">'instantiate public form object of frmMain, which we will use to reference later on from frmFader
 Public mainfrm As New frmMain

 Sub Main()
   'display the main form.
   mainfrm.Show()

   'keep the application running...
   Application.Run()
 End Sub</pre>
<p>2. Modify the Visual Studio Project Properties, uncheck &#8220;Use Application Framework&#8221; and choose Startup object, &#8220;Sub Main&#8221;.</p>
<p><img class="alignnone size-medium wp-image-206" title="prop" src="http://www.devtrends.com/wp-content/uploads/2009/08/prop-300x216.jpg" alt="prop" width="300" height="216" /></p>
<p>~</p>
<p><em><span style="text-decoration: underline;">frmFader :: &#8220;Screensaver&#8221; Fader Form</span></em></p>
<p>Lets create the next form, frmFader. Right click on your project and choose Add &gt; Windows Form, and name the form frmFader. Immediate make the following design modifications to your new form:</p>
<p>1. Change WindowState to Maximized.</p>
<p>2. TopMost to True.</p>
<p>3. ShowInTaskbar to False.</p>
<p>4. FormBorderStyle to None.</p>
<p>5. BackColor to Black.</p>
<p>Next we&#8217;ll modify the code behind the frmFader form that will make the form 50% transparent or 0% transparent, depending on the time of day. Remember, I needed an application that would black the screen out during a certain time window.</p>
<p>1. At the top of the code, add the following statements, which will be used to watch if the mouse is moved:</p>
<pre style="padding-left: 30px;">Public mousex As Integer
Public mousey As Integer</pre>
<p>2. In the Form Load sub, add the following code:</p>
<pre style="padding-left: 30px;">'stop Timer1 and Timer2 on frmMain
mainfrm.Timer1.Enabled = False
mainfrm.Timer2.Enabled = False

'set current mouse positions
mousex = MousePosition.X
mousey = MousePosition.Y

'hide the mouse cursor
Cursor.Hide()

'get the current hour
Dim curHour As Integer
curHour = Hour(Now())

'if the time is between 8am and 5pm then use 50% otherwise 100%
If curHour &gt;= 8 And curHour &lt;= 17 Then
  Me.Opacity = 0.5
Else
  Me.Opacity = 1
End If</pre>
<p>The comment lines explain most of what the code is doing. However, in the beginning of the code, I have it stop the Timers on the calling form (frmMain). This is required otherwise you would get multiple &#8220;screensavers&#8221; appear every 3 minutes.</p>
<p>3. In the Form Closing sub, we must add the following code to ensure the screensaver will reappear (we did stop the timers and hid the mouse cursor, remember?):</p>
<pre style="padding-left: 30px;">mainfrm.Timer1.Enabled = True
Cursor.Show()</pre>
<p>4. Finally, lets watch for mouse movement on the form as we want to close the form when the mouse is moved. In the Form Mousemove sub, add the following code:</p>
<pre style="padding-left: 30px;">If mousex &lt;&gt; MousePosition.X Or mousey &lt;&gt; MousePosition.Y Then
  'the mouse moved... lets close this overlayed form
  Me.Close()
End If</pre>
<p>That&#8217;s it&#8230;I&#8217;m out. If you want to cheat, just download the source code below. And as always, use this stuff at your own risk.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2009/08/kiosk.zip">Download the kiosk source code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/creating-a-custom-web-browser/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Custom Workflow Actions (Part 3 of 3)</title>
		<link>http://www.devtrends.com/index.php/custom-workflow-actions-part-3-of-3/</link>
		<comments>http://www.devtrends.com/index.php/custom-workflow-actions-part-3-of-3/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 03:25:02 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Workflow Actions]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=59</guid>
		<description><![CDATA[…this is a continuation of Custom Workflow Actions (Part 2 of 3)… As a recap, we are creating a custom workflow action that allows you to send an email with...]]></description>
			<content:encoded><![CDATA[<p>…this is a continuation of <a title="Custom Workflow Actions (Part 2 of 3)" href="http://www.devtrends.com/index.php/custom-workflow-actions-part-2-of-3/" target="_self">Custom Workflow Actions (Part 2 of 3)</a>…</p>
<p>As a recap, we are creating a custom workflow action that allows you to send an email with the attachments from a specified list in your site. The custom workflow action will allow you to configure four user input fields: (a) the Email Content; (b) the Send From Email; (c) the SMTP Host; and (d) the Associated List.</p>
<p>Although this project can be broken down into three sequential steps, these three steps are so closely intertwined that content from all three are required by the other three. With that stated, read all three sections, play around, then begin your actual development. The three steps are:</p>
<p>Step One: Create and Compile your .NET Workflow Activity<br />
Step Two: Modify or Create .ACTIONS file and Add to Authorized Assemblies<br />
<strong>Step Three: Deploy to WSS server and GAC</strong></p>
<h2>Step Three: Deploy to WSS server and GAC</h2>
<p>This step assumes you successfully completed Part 1 of 3 and Part 2 of 3. This Part is considerably shorter than 1 and 2 because you will likely run through the steps in the Part many times as your debug your SharePoint Workflow action DLL.</p>
<h3>Copy the Compiled Assembly DLL to WSS</h3>
<p>Although some people recommend deploying your DLL to a specific folder under the Windows folder, I recommend for this project and other projects to deploy the DLL into the SharePoint folder structure. Therefore, we will deploy your DLL to the SharePoint folder: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI</p>
<p>Let’s copy the latest compile from your Visual Studio project as was in Part 1 of 3 to the SharePoint folder listed above.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image10.jpg"><img class="alignnone size-full wp-image-60" title="part-2-image10" src="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image10.jpg" alt="" width="500" height="357" /></a></p>
<p>Next, we will need to use the gacutil.exe tool to add the DLL to the GAC cache. Run the following commands from a command prompt at the location of the DLL:</p>
<p>C:\&#8230;\web server extensions\12\ISAPI&gt;gacutil /I devtrends.EmailAttachments.dll</p>
<p>You should receive a message similar to: “Assembly successfully added to the cache”</p>
<p>If you received a bad command or filename error, then the gacutil.exe application may not be readily available to the command prompt. The gacutil.exe is a tool that is included with the .NET framework, specifically all .NET frameworks. Depending on the level of .NET framework you wrote the program in, you need that level or higher of the gacutil.exe application. For the purpose of this article, the gacutil.exe version is 3.5, and the gacutil.exe was copied to the C:\&#8230;\web server extensions\12\ISAPI folder. You may need to search your computer for the gacutil.exe and copy it to the SharePoint folder that you copied your compiled DLL.</p>
<p>Finally, you will need to restart your Information Information Server, so issue the command iisreset:</p>
<p>C:\&#8230;\web server extensions\12\ISAPI&gt;iisreset</p>
<p>Open SharePoint Designer, you should now have the custom action in your list of Workflow actions.</p>
<p>I hope this article was helpful. If you have questions please submit them as a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/custom-workflow-actions-part-3-of-3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Custom Workflow Actions (Part 2 of 3)</title>
		<link>http://www.devtrends.com/index.php/custom-workflow-actions-part-2-of-3/</link>
		<comments>http://www.devtrends.com/index.php/custom-workflow-actions-part-2-of-3/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 03:22:04 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Workflow Actions]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=48</guid>
		<description><![CDATA[…this is a continuation of Custom Workflow Actions (Part 1 of 3)… As a recap, we are creating a custom workflow action that allows you to send an email with...]]></description>
			<content:encoded><![CDATA[<p>…this is a continuation of <a title="Custom Workflow Actions (Part 1 of 3)" href="http://www.devtrends.com/index.php/custom-workflow-actions-part-1-of-3/" target="_self">Custom Workflow Actions (Part 1 of 3)</a>…</p>
<p>As a recap, we are creating a custom workflow action that allows you to send an email with the attachments from a specified list in your site. The custom workflow action will allow you to configure four user input fields: (a) the Email Content; (b) the Send From Email; (c) the SMTP Host; and (d) the Associated List.</p>
<p>Although this project can be broken down into three sequential steps, these three steps are so closely intertwined that content from all three are required by the other three. With that stated, read all three sections, play around, then begin your actual development. The three steps are:</p>
<p>Step One: Create and Compile your .NET Workflow Activity<br />
<strong>Step Two: Modify or Create .ACTIONS file and Add to Authorized Assemblies</strong><br />
Step Three: Deploy to WSS server and GAC</p>
<h2>Step Two: Modify or Create .ACTIONS file and Add to Authorized Assemblies</h2>
<p>First we will sign our new assembly as was created in Part 1 of 3 of this article. The signing process is required as we will extract the public key token from the assembly to use in the .ACTIONS file and the authorized assemblies list.</p>
<p>Let’s begin by opening up the Visual Studio project we created in Part 1 of 3, so open Visual Studio 2008.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/image11.jpg"><img class="alignnone size-medium wp-image-49" title="image11" src="http://www.developingtrends.net/wp-content/uploads/2008/08/image11.jpg" alt="" width="87" height="77" /></a></p>
<h3>Signing Assembly</h3>
<p>Once the project is open, click on Project and then the project Properties menu option.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image2.jpg"><img class="alignnone size-full wp-image-50" title="part-2-image2" src="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image2.jpg" alt="" width="500" height="357" /></a></p>
<p>First, in the project properties tab for informational purposes, look at the Assembly name and the Default namespace; these should be the same as your class and the name of your project when you created the project.</p>
<p>Click on the Signing side-tab, check the box to Sign the assembly and then select the dropdown list and choose &lt;New…&gt;.</p>
<p>In the Create Strong Name Key window, type in the Key file name, using the same name as your project and class, uncheck Protect my key file with a password, and then click OK.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image3.jpg"><img class="alignnone size-medium wp-image-51" title="part-2-image3" src="http://www.devtrends.com/wp-content/uploads/2008/08/part-2-image3-300x190.jpg" alt="" width="300" height="190" /></a></p>
<p>Your project should now be signed, as shown below:</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image4.jpg"><img class="alignnone size-full wp-image-52" title="part-2-image4" src="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image4.jpg" alt="" width="500" height="358" /></a></p>
<h3>Acquiring the Public Key Token</h3>
<p>Hopefully by now your code from Part 1 of 3 compiles successfully. If not, you must first fix and successfully compile your code. After your code is compiled, you will need to acquire the public key token from the compiled code. This process is done through using the Strong Name Tool (sn.exe) application that comes with the Visual Studio environment.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/k5b5tt23(VS.80).aspx">http://msdn.microsoft.com/en-us/library/k5b5tt23(VS.80).aspx</a></p>
<p>To simplify acquiring the public key token, we can add this application as an external tool in the Visual Studio environment. Click on Tools and then External Tools…</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image5.jpg"><img class="alignnone size-full wp-image-53" title="part-2-image5" src="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image5.jpg" alt="" width="500" height="357" /></a></p>
<p>Add a new External tool, name the title Display Public Key Token, with command: C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\sn.exe, and arguments: -Tp &#8220;$(TargetPath)&#8221;. Click OK.</p>
<p>Note: For those with Visual Studio 2005, the sn.exe tool is not located in the location as specified in this article. Search for sn.exe on your computer to determine the location.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image6.jpg"><img class="alignnone size-medium wp-image-54" title="part-2-image6" src="http://www.devtrends.com/wp-content/uploads/2008/08/part-2-image6-298x300.jpg" alt="" width="298" height="300" /></a></p>
<p>Click on Tools again, and this time choose Display Public Key Token from the menu. The Output window should display and the token will be listed in the contents of that window:</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image7.jpg"><img class="alignnone size-full wp-image-55" title="part-2-image7" src="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image7.jpg" alt="" width="500" height="357" /></a></p>
<p>Remember the public key token as you will use it twice during the rest of this Part 2 of 3.</p>
<h3>Modify or Create .ACTIONS file</h3>
<p>The .ACTIONS file defines how the Workflow action will be displayed SharePoint Designer 2007. The .ACTIONS file also defines how data is transformed to the Workflow code as created in Part 1 of 3.</p>
<p>Although this goes against standard procedure, we are going to add the actions configuration to the existing WSS.ACTIONS file. Be sure to back up the current WSS.ACTIONS file prior to editing.</p>
<p>Open WSS.ACTIONS in your favorite text editor and scroll to the bottom of the text document. Find the last &lt;/Action&gt; closing tag (“Action”, singular not plural) and paste the follow code immediately following the closing action tag:</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image8.jpg"><img class="alignnone size-full wp-image-56" title="part-2-image8" src="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image8.jpg" alt="" width="500" height="358" /></a></p>
<p class="MsoNormal"><span> </span>&lt;Action Name=&#8221;Email List Attachments&#8221;</p>
<p class="MsoNormal"><span> </span>ClassName=&#8221;devtrends.EmailAttachments.SendEmailwithListAttachments&#8221;</p>
<p class="MsoNormal"><span> </span>Assembly=&#8221; devtrends.EmailAttachments, Version=1.0.0.0, Culture=neutral, PublicKeyToken=977438f55cbfd7aa&#8221;</p>
<p class="MsoNormal"><span> </span>AppliesTo=&#8221;all&#8221;</p>
<p class="MsoNormal"><span> </span>Category=&#8221;devtrends&#8221;&gt;</p>
<p class="MsoNormal"><span> </span>&lt;RuleDesigner Sentence=&#8221;Send %1 from %2 via SMTP host %3. Send attachments from list %4.&#8221;&gt;</p>
<p class="MsoNormal"><span> </span>&lt;FieldBind Field=&#8221;To,CC,Subject,Body&#8221; Text=&#8221;this message&#8221; DesignerType=&#8221;Email&#8221; Id=&#8221;1&#8243;/&gt;</p>
<p class="MsoNormal"><span> </span>&lt;FieldBind Field=&#8221;FromUser&#8221; Text=&#8221;this user&#8221; Id=&#8221;2&#8243; DesignerType=&#8221;TextArea&#8221;/&gt;</p>
<p class="MsoNormal"><span> </span>&lt;FieldBind Field=&#8221;SMTPServerName&#8221; Text=&#8221;SMTP Server&#8221; Id=&#8221;3&#8243; DesignerType=&#8221;TextArea&#8221;/&gt;</p>
<p class="MsoNormal"><span> </span>&lt;FieldBind Field=&#8221;ListId,ListItem&#8221; Text=&#8221;this list&#8221; Id=&#8221;4&#8243; DesignerType=&#8221;ChooseListItem&#8221;/&gt;</p>
<p class="MsoNormal"><span> </span>&lt;/RuleDesigner&gt;</p>
<p class="MsoNormal"><span> </span>&lt;Parameters&gt;</p>
<p class="MsoNormal"><span> </span>&lt;Parameter Name=&#8221;To&#8221; Type=&#8221;System.Collections.ArrayList, mscorlib&#8221; Direction=&#8221;In&#8221; /&gt;</p>
<p class="MsoNormal"><span> </span>&lt;Parameter Name=&#8221;CC&#8221; Type=&#8221;System.Collections.ArrayList, mscorlib&#8221; Direction=&#8221;Optional&#8221; /&gt;</p>
<p class="MsoNormal"><span> </span>&lt;Parameter Name=&#8221;Subject&#8221; Type=&#8221;System.String, mscorlib&#8221; Direction=&#8221;In&#8221; /&gt;</p>
<p class="MsoNormal"><span> </span>&lt;Parameter Name=&#8221;Body&#8221; Type=&#8221;System.String, mscorlib&#8221; Direction=&#8221;Optional&#8221; /&gt;</p>
<p class="MsoNormal"><span> </span>&lt;Parameter Name=&#8221;FromUser&#8221; Type=&#8221;System.String, mscorlib&#8221; Direction=&#8221;In&#8221; /&gt;</p>
<p class="MsoNormal"><span> </span>&lt;Parameter Name=&#8221;SMTPServerName&#8221; Type=&#8221;System.String, mscorlib&#8221; Direction=&#8221;In&#8221; InitialValue=&#8221;127.0.0.1&#8243; /&gt;</p>
<p class="MsoNormal"><span> </span>&lt;Parameter Name=&#8221;__Context&#8221; Type=&#8221;Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions&#8221; Direction=&#8221;In&#8221;/&gt;</p>
<p class="MsoNormal"><span> </span>&lt;Parameter Name=&#8221;ListId&#8221; Type=&#8221;System.String, mscorlib&#8221; Direction=&#8221;In&#8221; /&gt;</p>
<p class="MsoNormal"><span> </span>&lt;Parameter Name=&#8221;ListItem&#8221; Type=&#8221;System.Int32, mscorlib&#8221; Direction=&#8221;In&#8221; /&gt;</p>
<p class="MsoNormal"><span> </span>&lt;/Parameters&gt;</p>
<p class="MsoNormal"><span> </span>&lt;/Action&gt;</p>
<p class="MsoNormal">
<p>Replace the public key token value in the first line with the public key token you acquired from earlier in this Part 2 of 3. Save the WSS.ACTIONS file.</p>
<h3>Authorize the Assembly</h3>
<p>In this step we will add our new assembly to the authorized assembly list. This list is stored in the web.config file for your SharePoint Services installation. The standard location for this file will be: C:\Inetpub\wwwroot\wss\VirtualDirectories\80\</p>
<p>Open the web.config file using your favorite text editor and scroll to the bottom of the web.config file. In the System.Workflow.ComponentModel.WorkflowCompiler, authorizedTypes section add the follow line:</p>
<p class="MsoNormal">&lt;authorizedType Assembly=&#8221;devtrends.EmailAttachments, Version=1.0.0.0, Culture=neutral, PublicKeyToken=977438f55cbfd7aa&#8221; Namespace=&#8221;devtrends.EmailAttachments&#8221; TypeName=&#8221;*&#8221; Authorized=&#8221;True&#8221; /&gt;</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image9.jpg"><img class="alignnone size-full wp-image-57" title="part-2-image9" src="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image9.jpg" alt="" width="500" height="358" /></a></p>
<p>Be sure to change the PublicKeyToken field to match the public key token as was acquired earlier in this Part 2 of 3.</p>
<p>Save the web.config file.</p>
<p>Please continue to <a title="Custom Workflow Actions (Part 3 of 3)" href="http://www.devtrends.com/index.php/custom-workflow-actions-part-3-of-3/" target="_self">Custom Workflow Actions (Part 3 of 3)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/custom-workflow-actions-part-2-of-3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Custom Workflow Actions (Part 1 of 3)</title>
		<link>http://www.devtrends.com/index.php/custom-workflow-actions-part-1-of-3/</link>
		<comments>http://www.devtrends.com/index.php/custom-workflow-actions-part-1-of-3/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 03:05:08 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Workflow Actions]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=35</guid>
		<description><![CDATA[A recent SharePoint project on my plate had a specific requirement that every item added to a list must be emailed to a specific email address. At the time of...]]></description>
			<content:encoded><![CDATA[<p>A recent SharePoint project on my plate had a specific requirement that every item added to a list must be emailed to a specific email address. At the time of the meeting, this requirement seemed to be a simple requirement. While stating that the requirement was possible, which was based on a vague memory of emailing functionality in the SharePoint Designer workflow action list, I decided to agree on making it happen.&lt;!&#8211;more&#8211;&gt;</p>
<p>What I did not realize was that the workflow actions in SharePoint Designer are quite basic. I had built up in my mind that the workflow capabilities of SharePoint were powerful from what I heard from so many individuals. What I did not realize was, while the fact that SharePoint workflows are powerful, to make them perform unique tasks it would require considerable involvement.</p>
<p>Unfortunately for me, I had a deadline to complete the task within two days. Thus began the conquering of creating a custom workflow action. Since much of the information I found on the Internet seemed to be missing pieces of the puzzle, here is my attempt to create a complete tutorial on creating a custom workflow action in Visual Studio 2008 that is applicable in SharePoint Designer and Windows SharePoint Services.</p>
<h2>Requirements</h2>
<p>Microsoft SharePoint Designer 2007, Microsoft Visual Studio 2008, Microsoft Windows SharePoint Services, and patience.</p>
<p>If programming for SharePoint is new to you, patience will serve you well. I was very frustrated for the two days while I figured out and then produced what I am going to explain to you below.</p>
<h2>Fundamentals</h2>
<p>The workflow functionality of SharePoint is based on the Windows Workflow Foundations (WWF) programming model, therefore if you have experience with WWF you may find programming workflow actions for SharePoint intuitive. Microsoft Windows SharePoint Services (WSS) is built on .NET Framework technology, which we will be utilizing for the workflow action program. If you understand both of these technologies well, creating a custom workflow action will be a breeze.</p>
<h2>Creating a Custom Workflow Action</h2>
<p>Enough with the preliminary text, let’s get started with creating the custom workflow action.</p>
<p>For the demonstration, we will be creating a custom workflow action that allows you to send an email with the attachments from a specified list in your site. The custom workflow action will allow you to configure four user input fields: (a) the Email Content; (b) the Send From Email; (c) the SMTP Host; and (d) the Associated List.</p>
<p>Although this project can be broken down into three sequential steps, these three steps are so closely intertwined that content from all three are required by the other three. With that stated, read all three steps, play around, then begin your actual development. The three steps are:</p>
<p><strong>Step One: Create and Compile your .NET Workflow Activity</strong><br />
Step Two: Modify or Create .ACTIONS file and Add to Authorized Assemblies<br />
Step Three: Deploy to WSS server and GAC</p>
<h2>Step One: Create and Compile your .NET Workflow Activity</h2>
<h3>Project Environment Setup</h3>
<p>Let’s begin by setting up the Visual Studio project and the environment, so open Visual Studio 2008.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/image1.jpg"><img class="size-medium wp-image-36 alignnone" title="image1" src="http://www.developingtrends.net/wp-content/uploads/2008/08/image1.jpg" alt="" width="87" height="77" /></a></p>
<p>In Visual Studio 2008, start a new Project by clicking on File &gt; New Project.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/image2.jpg"><img class="alignnone size-medium wp-image-38" title="image2" src="http://www.developingtrends.net/wp-content/uploads/2008/08/image2.jpg" alt="" width="243" height="150" /></a></p>
<p>In the New Project window, choose Workflow Activity Library and name the activity the same name you will use for the rest of the project. For the purposes of this demonstration, we will name the project <strong>devtrends.EmailAttachments</strong>. Click OK.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/image31.jpg"><img class="alignnone size-full wp-image-42" title="image31" src="http://www.developingtrends.net/wp-content/uploads/2008/08/image31.jpg" alt="" width="500" height="306" /></a></p>
<p>Since a custom workflow action does not have any graphical interface and in addition we are creating a single workflow activity, go ahead and immediately view the code for the project.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image1.jpg"><img class="alignnone size-full wp-image-44" title="part-2-image1" src="http://www.developingtrends.net/wp-content/uploads/2008/08/part-2-image1.jpg" alt="" width="500" height="357" /></a></p>
<p>Next, we will add the references to two DLLs that are associated with the installation of Windows SharePoint Services (WSS). These files will reside on the server that runs WSS, which is likely in the path: \\server_name\c$\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\</p>
<p>Copy the files:</p>
<p>Microsoft.SharePoint.dll<br />
Microsoft.SharePoint.xml<br />
Microsoft.sharepoint.WorkflowActions.dll<br />
Microsoft.sharepoint.WorkflowActions.xml</p>
<p>to your local computer, using the destination location, C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\.</p>
<p>Now that those files are copied to your local development computer, return to the Visual Studio project and add these two DLLs as references.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2008/08/image5.jpg"><img class="alignnone size-full wp-image-45" title="image5" src="http://www.developingtrends.net/wp-content/uploads/2008/08/image5.jpg" alt="" width="500" height="357" /></a></p>
<p>Now, add a few “using” statements to include the required namespaces. The namespace list for this project is as shown below, with the additional statements added at the end of the “using” line up.</p>
<p>Just two more changes, as shown as below: (a) change the name of the partial class to “SentEmailwithListAttachments” by modifying the first line to be (ensure that you are not editing the Designer.cs file); and (b) Add the five Using statements, Microsoft.SharePoint, Microsoft.SharePoint.Workflow, Microsoft.SharePoint.WorkflowActions, System.Net.Mail and System.IO.</p>
<p>Now that we are ready to create the SharePoint Workflow Activity, let’s begin by copying and pasting the following code into your partial class, SendEmailwithListAttachments:</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #0000ff;">#region</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> DepedencyProperties for the Activity</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #2b91af;">DependencyProperty</span> BCCProperty = <span style="color: #2b91af;">DependencyProperty</span>.Register(<span style="color: #a31515;">&#8220;BCC&#8221;</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">ArrayList</span>), <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">SentEmailwithListAttachments</span>));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #2b91af;">DependencyProperty</span> BodyProperty = <span style="color: #2b91af;">DependencyProperty</span>.Register(<span style="color: #a31515;">&#8220;Body&#8221;</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #0000ff;">string</span>), <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">SentEmailwithListAttachments</span>));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #2b91af;">DependencyProperty</span> CCProperty = <span style="color: #2b91af;">DependencyProperty</span>.Register(<span style="color: #a31515;">&#8220;CC&#8221;</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">ArrayList</span>), <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">SentEmailwithListAttachments</span>));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #2b91af;">DependencyProperty</span> SubjectProperty = <span style="color: #2b91af;">DependencyProperty</span>.Register(<span style="color: #a31515;">&#8220;Subject&#8221;</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #0000ff;">string</span>), <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">SentEmailwithListAttachments</span>));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #2b91af;">DependencyProperty</span> ToProperty = <span style="color: #2b91af;">DependencyProperty</span>.Register(<span style="color: #a31515;">&#8220;To&#8221;</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">ArrayList</span>), <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">SentEmailwithListAttachments</span>));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #2b91af;">DependencyProperty</span> FromUserProperty = <span style="color: #2b91af;">DependencyProperty</span>.Register(<span style="color: #a31515;">&#8220;FromUser&#8221;</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #0000ff;">string</span>), <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">SentEmailwithListAttachments</span>));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #2b91af;">DependencyProperty</span> SMTPServerNameProperty = <span style="color: #2b91af;">DependencyProperty</span>.Register(<span style="color: #a31515;">&#8220;SMTPServerName&#8221;</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #0000ff;">string</span>), <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">SentEmailwithListAttachments</span>));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #2b91af;">DependencyProperty</span> __ContextProperty = <span style="color: #2b91af;">DependencyProperty</span>.Register(<span style="color: #a31515;">&#8220;__Context&#8221;</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">WorkflowContext</span>), <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">SentEmailwithListAttachments</span>));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #2b91af;">DependencyProperty</span> ListIdProperty = <span style="color: #2b91af;">DependencyProperty</span>.Register(<span style="color: #a31515;">&#8220;ListId&#8221;</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #0000ff;">string</span>), <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">SentEmailwithListAttachments</span>));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #2b91af;">DependencyProperty</span> ListItemProperty = <span style="color: #2b91af;">DependencyProperty</span>.Register(<span style="color: #a31515;">&#8220;ListItem&#8221;</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #0000ff;">int</span>), <span style="color: #0000ff;">typeof</span>(<span style="color: #2b91af;">SentEmailwithListAttachments</span>));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #0000ff;">#endregion</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #0000ff;">#region</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> Properties</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">[<span style="color: #2b91af;">ValidationOption</span>(<span style="color: #2b91af;">ValidationOption</span>.Required)]</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #2b91af;">WorkflowContext</span> __Context</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">get</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">return</span> (<span style="color: #2b91af;">WorkflowContext</span>)(<span style="color: #0000ff;">base</span>.GetValue(__ContextProperty));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">set</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">base</span>.SetValue(<span style="color: #2b91af;">SentEmailwithListAttachments</span>.__ContextProperty, <span style="color: #0000ff;">value</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">[<span style="color: #2b91af;">ValidationOption</span>(<span style="color: #2b91af;">ValidationOption</span>.Required)]</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> ListId</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">get</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">string</span>)(<span style="color: #0000ff;">base</span>.GetValue(ListIdProperty));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">set</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">base</span>.SetValue(<span style="color: #2b91af;">SentEmailwithListAttachments</span>.ListIdProperty, <span style="color: #0000ff;">value</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">[<span style="color: #2b91af;">ValidationOption</span>(<span style="color: #2b91af;">ValidationOption</span>.Required)]</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> ListItem</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">get</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">int</span>)(<span style="color: #0000ff;">base</span>.GetValue(ListItemProperty));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">set</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">base</span>.SetValue(<span style="color: #2b91af;">SentEmailwithListAttachments</span>.ListItemProperty, <span style="color: #0000ff;">value</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">[<span style="color: #2b91af;">ValidationOption</span>(<span style="color: #2b91af;">ValidationOption</span>.Required)]</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> FromUser</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">get</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">string</span>)<span style="color: #0000ff;">base</span>.GetValue(FromUserProperty);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">set</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">base</span>.SetValue(FromUserProperty, <span style="color: #0000ff;">value</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">[<span style="color: #2b91af;">ValidationOption</span>(<span style="color: #2b91af;">ValidationOption</span>.Required)]</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> SMTPServerName</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">get</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">string</span>)<span style="color: #0000ff;">base</span>.GetValue(SMTPServerNameProperty);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">set</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">base</span>.SetValue(SMTPServerNameProperty, <span style="color: #0000ff;">value</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">[<span style="color: #2b91af;">ValidationOption</span>(<span style="color: #2b91af;">ValidationOption</span>.Optional)]</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> Body</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">get</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">string</span>)<span style="color: #0000ff;">base</span>.GetValue(BodyProperty);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">set</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">base</span>.SetValue(BodyProperty, <span style="color: #0000ff;">value</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">[<span style="color: #2b91af;">ValidationOption</span>(<span style="color: #2b91af;">ValidationOption</span>.Optional)]</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #2b91af;">ArrayList</span> CC</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">get</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">return</span> (<span style="color: #2b91af;">ArrayList</span>)<span style="color: #0000ff;">base</span>.GetValue(CCProperty);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">set</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">base</span>.SetValue(CCProperty, <span style="color: #0000ff;">value</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">[<span style="color: #2b91af;">ValidationOption</span>(<span style="color: #2b91af;">ValidationOption</span>.Required)]</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> Subject</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">get</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">string</span>)<span style="color: #0000ff;">base</span>.GetValue(SubjectProperty);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">set</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">base</span>.SetValue(SubjectProperty, <span style="color: #0000ff;">value</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">[<span style="color: #2b91af;">ValidationOption</span>(<span style="color: #2b91af;">ValidationOption</span>.Required)]</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> <span style="color: #2b91af;">ArrayList</span> To</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">get</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">return</span> (<span style="color: #2b91af;">ArrayList</span>)<span style="color: #0000ff;">base</span>.GetValue(ToProperty);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">set</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">base</span>.SetValue(ToProperty, <span style="color: #0000ff;">value</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #0000ff;">#endregion</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #0000ff;">#region</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> Initialization</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">public</span> SentEmailwithListAttachments()</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">InitializeComponent();</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #0000ff;">#endregion</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #0000ff;">#region</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> Overidden Method (ActivityExecutionStatus)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #2b91af;">ActivityExecutionStatus</span> Execute(<span style="color: #2b91af;">ActivityExecutionContext</span> executionContext)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">try</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//Send the email</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//grab the Activity for the Lookup Fields to be based on</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #2b91af;">Activity</span> myActivity = executionContext.Activity;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">while</span> (myActivity.Parent != <span style="color: #0000ff;">null</span>)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">myActivity = myActivity.Parent;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//Send the email with attachments!!</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">SendEmail(myActivity);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">finally</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//nada</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//Indicate the activity has closed </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">return</span> <span style="color: #2b91af;">ActivityExecutionStatus</span>.Closed;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #0000ff;">#endregion</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #0000ff;">#region</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> SendEMail</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> SendEmail(<span style="color: #2b91af;">Activity</span> parent)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//STEP 1: Create a new object that will send the email</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">System.Net.Mail.<span style="color: #2b91af;">MailMessage</span> msg = <span style="color: #0000ff;">new</span> System.Net.Mail.<span style="color: #2b91af;">MailMessage</span>();</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//STEP 2: Create the fromAddress variable and then determine the from email address</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//Create an object to specify the from address for the email </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">System.Net.Mail.<span style="color: #2b91af;">MailAddress</span> fromAddress;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">try</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//set the email address</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">fromAddress = <span style="color: #0000ff;">new</span> System.Net.Mail.<span style="color: #2b91af;">MailAddress</span>(FromUser);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">catch</span> (System.<span style="color: #2b91af;">Exception</span> Ex)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">fromAddress = <span style="color: #0000ff;">new</span> System.Net.Mail.<span style="color: #2b91af;">MailAddress</span>(<span style="color: #a31515;">&#8220;no-reply@domain.com&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//Set the from email address on the message object </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">msg.From = fromAddress;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//STEP 3: Determine who the email will be sent to, To and CC, and add those email addresses to the msg object created in STEP 1.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">try</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//Add the email addresses stored in the To property to the email message object </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int</span> i = 0; i &lt; To.Count; i++)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">msg.To.Add(To[i].ToString());</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">catch</span> (System.<span style="color: #2b91af;">Exception</span> Ex)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//errored out on the To list</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">msg.To.Add(<span style="color: #a31515;">&#8220;administrator@domain.com&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">try</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//Add the email addresses stored in the CC property to the email message object </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">if</span> (CC != <span style="color: #0000ff;">null</span>)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int</span> i = 0; i &lt; CC.Count; i++)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">msg.CC.Add(CC[i].ToString());</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">catch</span> (System.<span style="color: #2b91af;">Exception</span> Ex)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//errored out on the CC list&#8230; odd</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">msg.CC.Add(<span style="color: #a31515;">&#8220;administrator@domain.com&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//STEP 4: Create the subject line for this Email</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #2b91af;">String</span> mySubject = <span style="color: #a31515;">&#8220;&#8221;</span>;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">try</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//To include fields in the subject line from the List, uncomment the lines below</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//mySubject += Subject;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//mySubject += &#8221; (&#8221; + Helper.LookupString(this.__Context, this.ListId, this.ListItem, &#8220;My Field 1&#8243;) + &#8220;)&#8221;;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">mySubject = Subject;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">catch</span> (System.<span style="color: #2b91af;">Exception</span> Ex)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">mySubject = <span style="color: #a31515;">&#8220;ERR: Invalid Subject Line&#8221;</span>;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">msg.Subject = mySubject;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//STEP 5: Generate the message body</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//start the handling of the message body.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">msg.IsBodyHtml = <span style="color: #0000ff;">true</span>;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #2b91af;">String</span> myBody = Body;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//make SharePoint replace the Lookup Strings in the field</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">try</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//process the Add Lookup strings [%...%] from the Workflow configuration</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">myBody = <span style="color: #2b91af;">Helper</span>.ProcessStringField(myBody, parent, <span style="color: #0000ff;">this</span>.__Context);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">catch</span> (System.<span style="color: #2b91af;">Exception</span> Ex)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//nothing, couldn&#8217;t process strings for some reason.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">msg.Body = myBody;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//STEP 6: Add the file attachments as added on the list</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//begin file attachments&#8230;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//set current Site information and List</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">try</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//create a hierarchy of objects starting from the base SharePoint web to the List Item’s attachment collection</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #2b91af;">SPWeb</span> spWeb = (<span style="color: #2b91af;">SPWeb</span>)(__Context.Web);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #2b91af;">SPSite</span> Site = (<span style="color: #2b91af;">SPSite</span>)(__Context.Site);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #2b91af;">SPList</span> List = spWeb.Lists[<span style="color: #0000ff;">new</span> <span style="color: #2b91af;">Guid</span>(<span style="color: #0000ff;">this</span>.ListId)];</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #2b91af;">SPListItem</span> ListItem = List.GetItemById(<span style="color: #0000ff;">this</span>.ListItem);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//get file information from the list item attachment URL address</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #2b91af;">SPFolder</span> spFolder = spWeb.GetFolder(ListItem.Attachments.UrlPrefix);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//iterate all files in List Item (SPFileCollection)</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #2b91af;">SPFileCollection</span> ColOfFiles = spFolder.Files;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">foreach</span> (<span style="color: #2b91af;">SPFile</span> spFile <span style="color: #0000ff;">in</span> ColOfFiles)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//open a binary stream to transfer to the email message</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">string</span> strFileName = spFile.Name;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">System.IO.<span style="color: #2b91af;">Stream</span> binFile = spFile.OpenBinaryStream();</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//If needed, add the filename to the message body also.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//msg.Body += strFileName;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//add file to email message through binary stream</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">msg.Attachments.Add(<span style="color: #0000ff;">new</span> <span style="color: #2b91af;">Attachment</span>(binFile, strFileName));</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #0000ff;">catch</span> (System.<span style="color: #2b91af;">Exception</span> ex)</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//file attachment failed.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">msg.Body += <span style="color: #a31515;">&#8220;ERR: Attempted to add files: &#8220;</span> + ex.Message + ex.StackTrace;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//STEP 7: Create an object to represent the mail server and SEND the message </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">System.Net.Mail.<span style="color: #2b91af;">SmtpClient</span> client = <span style="color: #0000ff;">new</span> System.Net.Mail.<span style="color: #2b91af;">SmtpClient</span>(SMTPServerName);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//Set the credentials used to authenticate to the email server </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">client.UseDefaultCredentials = <span style="color: #0000ff;">true</span>;</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//Send the message</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">client.Send(msg);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//Use the follow Catch with a Try statement to write specific errors to a local disk file for debugging issues. (Requires System.IO)</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//}</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//catch (System.Exception Ex)</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//{</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">// create a writer and open the file</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//<span style="mso-spacerun: yes;"> </span>TextWriter tw = new StreamWriter(&#8220;c:\\error.log&#8221;);</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">// write a line of text to the file</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//<span style="mso-spacerun: yes;"> </span>tw.WriteLine(DateTime.Now + &#8221; &#8211; &#8221; + Ex.Message + Ex.StackTrace);</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">// close the stream</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//<span style="mso-spacerun: yes;"> </span>tw.Close();</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><span style="color: #008000;">//}</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: #0000ff;">#endregion</span></p>
<p>Compile the code; you will hopefully receive a Build Succeeded.</p>
<p>Please continue to <a href="http://www.devtrends.com/index.php/custom-workflow-actions-part-2-of-3/">Custom Workflow Actions (Part 2 of 3)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/custom-workflow-actions-part-1-of-3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

