You are currently browsing the tag archive for the 'Programming' tag.
http://msdn.microsoft.com/en-us/library/cc627284.aspx
In Microsoft Visual Studio 2008, you can create custom activities that can be consumed in workflows. Creating custom activities lets you encapsulate business logic that applies to different scenarios and that can be used in different workflows. This Microsoft Office Visual How To demonstrates how to create a custom activity to send an e-mail message with an attachment.
Creating a Custom Activity Project First, create a Visual Studio 2008 Workflow Activity Library project. To create a Visual Studio 2008 Workflow Activity Library project
Coding Custom Activity Now that you have a Custom Activity project, you must add code to send an e-mail message with an attachment. To add code to send an e-mail message with an attachment
Installing a Custom Activity Before you can use your custom activity, you must install it in the global assembly cache (GAC). For an assembly to be installed in the GAC, you must give it a strong name. To install the custom activity to the GAC
Now, that you have successfully installed your activity, you can use it from a workflow project. Creating a Workflow Project Next, you create a Sequential Workflow project to use your custom activity. To create a Visual Studio 2008 Sequential Workflow project
Adding a Custom Activity to the Toolbox Now that you have created your Sequential Workflow project, you must add your custom activity to your Toolbox before you can use it. To add the custom activity to the Visual Studio 2008 Toolbox
Adding a Custom Activity to the Workflow Now, you must add your custom activity to your simple workflow. To add the custom activity to the workflow
Note: The purpose of this demonstration is to show you how to create and consume a custom activity. In a real-world scenario, you would never hard-code these values. You would retrieve them programmatically, or possibly through an Initiation form or a Task form. Running the Workflow Project from Visual Studio 2008 Press F5 to run your workflow. When you activate this workflow on a document in a document library, an e-mail message is generated and sent with the attachment you specified. Figure 3. E-mail message with attachment
|
In the new version of the Content By Type webpart, I added the option to rollup items into a calendar. In a later post I will describe how you can do that using the webpart. In this post I will show you how I did it in the code. When you start it all seems very easy, but there were a few things that caused me some headaches. I hope you don’t run into them as well after reading this item.
Step 1 – Setting up the controls
I implemented all the calendar specific code in a special control:
public class SharePointCalendar : Control
In the CreateChildControls of my webpart, I just add this control to the collection:
protected override void CreateChildControls()
{
base.CreateChildControls();
SharePointCalendar calendar = new SharePointCalendar();
Controls.Add(calendar);
}
In the CreateChildControls of my SharePointCalendar class, I setup the SPCalendarView and add it to the controls collection:
private SPCalendarView _view;
/// <summary>
/// Create the SharePoint calendar. Uses the SharePoint SPCalendarView object.
/// </summary>
protected override void CreateChildControls()
{
base.CreateChildControls();
_view = new SPCalendarView();
_view.EnableViewState = true;
_view.Width = Unit.Percentage(100);
_view.DataSource = GetCalendarItems();
DataBind();
Controls.Add(_view);
}
You can find SPCalendarView in the Microsoft.SharePoint.WebControls namespace.
Step 2 – Adding data and testing
The data that will be displayed in the calendar is loaded in GetCalendarItems. In this case it is dummy data, but you will get the idea:
private SPCalendarItemCollection GetCalendarItems()
{
// Create a new collection for the calendar items
// This is an item with a start and end date.
SPCalendarItemCollection items = new SPCalendarItemCollection();
// Add the first dummy item
SPCalendarItem item = new SPCalendarItem();
item.StartDate = DateTime.Now;
item.EndDate = DateTime.Now.AddHours(1);
item.hasEndDate = true;
item.Title = "First calendar item";
item.DisplayFormUrl = "/News";
item.Location = "Utrecht";
item.Description = "This is the first test item in the calendar rollup";
item.IsAllDayEvent = false;
item.IsRecurrence = false;
item.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
items.Add(item);
// Add the second item. This is an all day event.
SPCalendarItem item2 = new SPCalendarItem();
item2.StartDate = DateTime.Now.AddDays(-1);
item.hasEndDate = true;
item2.Title = "Second calendar item";
item2.DisplayFormUrl = "/News";
item2.Location = "Utrecht";
item2.Description = "This is the second test item in the calendar rollup";
item2.IsAllDayEvent = true;
item2.IsRecurrence = false;
item2.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
items.Add(item2);
// return the collection
return items;
}
If you now build your webpart and add it to a page, it should look like this:

Step 3 – The ViewType
Looks nice and it indeed it very simple to do. But now you click one of the links “Week” or “Day” to switch to the daily or weekly view. That doesn’t work. The webpart simply does what it does and it shows you the monthly view. If you look at the url however, you will see that the calendar view added a querystring parameter called “CalendarPeriod“.
Add the following snippet to the CreateChildControls of the SharePointCalendar to make it work:
if (Page.Request.QueryString["CalendarPeriod"] != null)
{
switch (Page.Request.QueryString["CalendarPeriod"].ToString().ToLower())
{
case "day":
_view.ViewType = "day";
break;
case "week":
_view.ViewType = "week";
break;
case "timeline":
_view.ViewType = "timeline";
break;
default:
_view.ViewType = "month";
break;
}
}
The documentation for the ViewType property shows you the possible values, but please notice that you need to set them in lower case!. Not sure what the option “timeline” does. It looks like a normal monthly view if you use it.
Step 4 – The DisplayFormUrl problem
The property DisplayFormUrl expects are relative url to the item that you added to the calendar. In the sample above, I added a url to the News site. If you look at the properties of the hyperlink, you will see this link:
The calendar view automatically adds a querystring parameter ID to your urls. In this case this is not a problem. In the Content By Type webpart however, I add the same links that are generated by the out of the box ContentQuery webpart. These urls look like this:
When you add “?ID=” to that url (that is what the calendar view does), your link will not work and the page will display an “Unknown error“:

In the first approach I tried to fix the urls in javascript, but that didn’t work. I was able to trim the “?ID=” bit, but something else kept on adding it back in. I ended up creating a page like the CopyUtil page. When I set the DisplayFormUrl property, I encode the Url that I want to redirect to and add that as a querystring parameter to my redirect page called “tstredirect.aspx”:
string link = /_layouts/CopyUtil.aspx?Use=id&Action=dispform&ItemId=1&ListId={70fbb8db-c7b8-4b32-bf77-f61a13b3e0fc}&WebId={087c3dd8-b0a9-4960-9509-da8887d979b6}&SiteId={9fb94730-cc85-4924-957f-7504f415fe0f}
string urlStart = SPContext.Current.Site.ServerRelativeUrl;
if (urlStart == "/")
urlStart = string.Empty;
link = string.Format("{0}/_layouts/tst/tstredirect.aspx?GoTo={1}", urlStart, System.Web.HttpUtility.UrlEncode(link));
item.DisplayFormUrl = link;
In that tstredirect page, I decode the querystring GoTo parameter and redirect to that url.
I am not very happy with that last approach, there should be a better way. If you have a suggestion, please let me know. So after all, it still is pretty easy to use the SPCalendarView in your webparts, if you are aware of these things. In the next post I will show you how I exactly implemented it in the Content By Type webpart.
Check permission with:
| Name | Description |
|---|---|
| SPSite.DoesUserHavePermissions (SPReusableAcl, SPBasePermissions) |
Returns a Boolean value indicates whether the user has permissions for the specified set of rights.
|
| SPSite.DoesUserHavePermissions (SPReusableAcl, SPBasePermissions, SPWeb) |
Returns a Boolean value that indicates whether the user has permissions for the specified Web site and set of rights.
|
| Name | Description |
|---|---|
| SPWeb.DoesUserHavePermissions (SPBasePermissions) |
Checks permissions of the current user for a specified set of rights and returns a Boolean value.
|
| SPWeb.DoesUserHavePermissions (String, SPBasePermissions) |
Checks permissions of the specified user for a specified set of rights and returns a Boolean value.
|
| Name | Description |
|---|---|
| SPList.DoesUserHavePermissions (SPBasePermissions) |
Checks the permissions of the current user on the list.
|
| SPList.DoesUserHavePermissions (SPBasePermissions, Boolean) |
Checks the permissions of the list, and, optionally. checks the folder permissions.
|
| SPList.DoesUserHavePermissions (SPUser, SPBasePermissions) |
Checks the permissions of a specified user on the list.
|
| Name | Description |
|---|---|
| SPListItem.DoesUserHavePermissions (SPBasePermissions) |
Checks whether the current user has the specified permissions to an item.
|
| SPListItem.DoesUserHavePermissions (SPUser, SPBasePermissions) |
Checks whether a specified user has the specified permissions to an item.
|
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.sppermissioncollection.aspx
SPSite oSiteCollection = SPContext.Current.Site;
using(SPWeb oWebsite = oSiteCollection.AllWebs["Site_Name"])
{
SPList oList = oWebsite.Lists["List_Name"];
SPPermissionCollection collPermissions = oList.Permissions;
SPUserCollection collUsers = oWebsite.Users;
foreach (SPUser oUser in collUsers)
{
foreach (SPPermission oPermission in collPermissions)
{
if (oUser.ID == oPermission.Member.ID)
{
Response.Write("User: " +
SPEncode.HtmlEncode(oUser.Name) +
" Permissions: " +
oPermission.PermissionMask.ToString() +
"<BR>");
}
}
}
}
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.sppermission.aspx
SPSite oSiteCollection = SPContext.Current.Site;
using(SPWeb oWebsite = oSiteCollection.AllWebs["Site_Name"])
{
SPList oList = oWebsite.Lists["List_Name"];
SPPermissionCollection collPermissions = oList.Permissions;
SPUserCollection collUsers = oWebsite.Users;
SPMember oMember = collUsers["User_Name"];
oList.Permissions[oMember].PermissionMask =
SPRights.AddListItems | SPRights.EditListItems;
}
SPList list = web.Lists["myList"];
SPListItem item = list.Items[0];item["myField"] = "my value";
item.SystemUpdate(false);
list.Update();
http://msdn.microsoft.com/en-us/library/ms196939.aspx
<And> and <Or> can only be used to compare 2 boolean expressions. Doing otherwise results in a runtime error in Sharepoint Services (described by the ever-helpful “Cannot complete this action. Please try again.” message).
For example, even though the following makes sense as a SQL construct, it will cause Sharepoint to throw an error:
<And> <Neq> <FieldRef Name="Status" /> <Value Type="Text">Completed</Value> </Neq> <Neq> <FieldRef Name="Status" /> <Value Type="Text">5-Closed</Value> </Neq> <Eq> <FieldRef Name="AssignedTo" LookupId="TRUE" /> <Value Type="int">[CurrentUser]</Value> </Eq> <Eq> <FieldRef Name="IsCurrent" /> <Value Type="Boolean">1</Value> </Eq> </And>
In order to correctly execute the CAML must be written comparing pairs of values. For example:
<And> <And> <Neq> <FieldRef Name="Status" /> <Value Type="Text">Completed</Value> </Neq> <Neq> <FieldRef Name="Status" /> <Value Type="Text">5-Closed</Value> </Neq> </And> <And> <Eq> <FieldRef Name="AssignedTo" LookupId="TRUE" /> <Value Type="int">[CurrentUser]</Value> </Eq> <Eq> <FieldRef Name="IsCurrent" /> <Value Type="Boolean">1</Value> </Eq> </And> </And>
http://sharepointmalarkey.wordpress.com/2008/08/21/sharepoint-internal-field-names/
| Title | InternalName |
| $Resources:RulesUrl $Resources:XomlUrl % Complete About Me Account Action Actual Work Address All Day Event Allow writers to view cached content Anniversary Append-Only Comments Approval Status Approver Comments Article Date Assigned To Assistant’s Name Assistant’s Phone Associated Content Type Associated Service Attachments Author Automatic Update Base Association Guid Billing Information Birthday Body Body Body Was Expanded Business Phone Business Phone 2 Byline Cacheability Callback Number Car Phone Categories Category Category Category Check for Changes Check In Comment Checked out User Children’s Names City Comments Comments Company Company Main Phone Company Phonetic Completed Computer Network Name Connection Type Contact Contact E-Mail Address Contact Name Contact Photo Contact Picture Content Category Content Type Content Type ID Content Type ID Contributor Copy Source Correct Body To Show Country/Region Coverage Created Created Created By Custom ID Number Data Date Completed Date Created Date Modified Date Occurred Date Picture Taken Deleted Department Department Description Description Description Discussion Subject Discussion Title Display Description Display Name Document Created By Document Modified By Due Date Duration Duration Duration Edit Edit Menu Table End Edit Menu Table Start Effective Permissions Mask E-mail 2 E-mail 3 Email Body E-Mail Calendar Date Stamp E-Mail Calendar Sequence E-Mail Calendar UID E-Mail Cc E-Mail From Email Messages E-Mail Sender E-Mail Subject E-Mail To Enabled Encoded Absolute URL End Date End Time Event Address Event Canceled Event Type Event Type Expires Extended Properties External Participant External Participant Reason Fax Number File Size File Size File Type File Type First Name First Name Phonetic Form Category Form Data Form Description Form ID Form Locale Form Name Form Name Form Relative Url Form Version Form_URN Format FTP Site Full Name FullBody Gender Government ID Number Group Type GUID Has Copy Destinations Has Custom Email Body Hidden Page Hobbies Home Address City Home Address Country Home Address Postal Code Home Address State Or Province Home Address Street Home Fax Home Phone Home Phone 2 Html File Link HTML File Type ID IM Address Image Caption Indentation Indentation Level Initials Instance ID Is Active Is Current Version Is Root Post Is Signed Is Site Admin ISDN Issue ID Issue Status Item Type Job Title Keywords Language Last Name Phonetic Last Printed Last Updated Less Link Level Limited Body Link List ID Location Manager’s Name MasterSeriesItemID Merge Message ID Middle Name Migrated GUID Mileage Mobile Phone Modified Modified Modified By More Link Name Name Name Name Name Nickname Office Order Order Organizational ID Number Other Address City Other Address Country Other Address Postal Code Other Address State Or Province Other Address Street Other Fax Other Phone Outcome Outcome owshiddenversion Page Content Page Icon Page Image Page Layout Pager Parent Folder Id Path Pending Modification Time Perform ACL Check Personal Website Picture Picture Height Picture Size Picture Width Post Posted By Posted By Posting Information Preview Preview Image Primary Item ID Primary Phone Priority Profession ProgId Property Bag Published Publisher Quoted Text Was Expanded Radio Phone Recurrence Recurrence ID RecurrenceData Redirect URL References Referred By Related Company Related Issues Relation Relink Replies Reply Required Field Resource Identifier Resource Type Response Reusable HTML Reusable Text Revision Rights Management Role Rollup Image Safe for Authenticated Use Scheduling End Date Scheduling Start Date ScopeId Select Select Selection Checkbox Send Email Notification Server Relative URL Shared File Index Shortest Thread-Index Shortest Thread-Index Id Shortest Thread-Index Id Lookup Show Combine View Show in Catalog Show Repair View SIP Address Source Source Name (Converted Document) Source Url Source Version (Converted Document) Spouse Start Date State/Province Status Status Style Definitions Subject Subject Subject Suffix Summary Links Summary Links 2 System Task Target Audiences Task Group Task Status Task Type Telex Template Id Template Link Thread Index Thread Topic Threading Threading Controls Thumbnail Thumbnail URL TimeZone Title Title Title Title Toggle Quoted Text Total Work Trimmed Body TTY-TDD Phone Type UDC Purpose UI Version UID Unique Id URL URL URL URL Path User Field 1 User Field 2 User Field 3 User Field 4 User ID Variation Group ID Variation Relationship Link Variations Vary by Custom Parameter Vary by HTTP Header Vary by Query String Parameters Vary by User Rights Version Version Virus Status Web Image URL Web Page Web Preview Wiki Content Workflow Association ID Workflow History Parent Instance Workflow Instance ID Workflow Item ID Workflow List ID Workflow Name Workflow Template ID Workflow Version Workspace WorkspaceUrl XMLTZone ZIP/Postal Code |
RulesUrl XomlUrl PercentComplete Notes Name AdminTaskAction ActualWork WorkAddress fAllDayEvent PublishingCacheAllowWriters Anniversary V3Comments _ModerationStatus _ModerationComments ArticleStartDate AssignedTo AssistantsName AssistantNumber PublishingAssociatedContentType Service Attachments _Author AutomaticUpdate BaseAssociationGuid BillingInformation Birthday Body MessageBody BodyWasExpanded WorkPhone Business2Number ArticleByLine PublishingCacheability CallbackNumber CarNumber Categories _Category Category PostCategory PublishingCacheCheckForChanges _CheckinComment CheckoutUser ChildrensNames WorkCity _Comments Comments Company CompanyNumber CompanyPhonetic Completed ComputerNetworkName ConnectionType PublishingContact PublishingContactEmail PublishingContactName _Photo PublishingContactPicture ContentCategory ContentType ContentTypeId CustomContentTypeId _Contributor _CopySource CorrectBodyToShow WorkCountry _Coverage Created Created_x0020_Date Author CustomerID Data DateCompleted _DCDateCreated _DCDateModified Occurred ImageCreateDate Deleted Department ol_Department AdminTaskDescription Comment DLC_Description DiscussionTitle DiscussionTitleLookup PublishingCacheDisplayDescription PublishingCacheDisplayName Created_x0020_By Modified_x0020_By TaskDueDate DLC_Duration Duration PublishingCacheDuration Edit _EditMenuTableEnd _EditMenuTableStart PermMask Email2 Email3 EmailBody EmailCalendarDateStamp EmailCalendarSequence EmailCalendarUid EmailCc EmailFrom RelevantMessages EmailSender EmailSubject EmailTo PublishingCacheEnabled EncodedAbsUrl _EndDate EndDate ol_EventAddress EventCanceled Event EventType Expires ExtendedProperties OffsiteParticipant OffsiteParticipantReason WorkFax File_x0020_Size FileSizeDisplay File_x0020_Type FileType FirstName FirstNamePhonetic FormCategory FormData FormDescription FormId FormLocale FormName LinkTemplateName FormRelativeUrl FormVersion FormURN _Format FTPSite FullName FullBody Gender GovernmentIDNumber Group GUID _HasCopyDestinations HasCustomEmailBody PublishingHidden Hobbies HomeAddressCity HomeAddressCountry HomeAddressPostalCode HomeAddressStateOrProvince HomeAddressStreet HomeFaxNumber HomePhone Home2Number xd_ProgID HTML_x0020_File_x0020_Type ID IMAddress PublishingImageCaption Indentation IndentLevel Initials InstanceID IsActive _IsCurrentVersion IsRootPost xd_Signature IsSiteAdmin ISDNNumber LinkIssueIDNoMenu IssueStatus FSObjType JobTitle Keywords Language LastNamePhonetic _LastPrinted DiscussionLastUpdated LessLink _Level LimitedBody WorkflowLink List Location ManagersName MasterSeriesItemID Combine MessageId MiddleName _PublishingMigratedGuid Mileage CellPhone Last_x0020_Modified Modified Editor MoreLink BaseName FileLeafRef LinkFilename LinkFilenameNoMenu NameOrTitle Nickname Office AdminTaskOrder Order OrganizationalIDNumber OtherAddressCity OtherAddressCountry OtherAddressPostalCode OtherAddressStateOrProvince OtherAddressStreet OtherFaxNumber OtherNumber Outcome WorkflowOutcome owshiddenversion PublishingPageContent PublishingPageIcon PublishingPageImage PublishingPageLayout PagerNumber ParentFolderId FileDirRef PendingModTime PublishingCachePerformACLCheck PersonalWebsite Picture ImageHeight ImageSize ImageWidth BodyAndMore PersonImage PersonViewMinimal StatusBar PreviewOnForm PublishingPreviewImage Item PrimaryNumber Priority Profession ProgId MetaInfo PublishedDate _Publisher QuotedTextWasExpanded RadioNumber fRecurrence RecurrenceID RecurrenceData RedirectURL EmailReferences ReferredBy TaskCompanies RelatedIssues _Relation RepairDocument ItemChildCount ReplyNoGif RequiredField _Identifier _ResourceType AttendeeStatus ReusableHtml ReusableText _Revision _RightsManagement Role PublishingRollupImage PublishingAuthenticatedUse PublishingExpirationDate PublishingStartDate ScopeId SelectFilename SelectTitle SelectedFlag SendEmailNotification ServerUrl _SharedFileIndex ShortestThreadIndex ShortestThreadIndexId ShortestThreadIndexIdLookup ShowCombineView ShowInCatalog ShowRepairView SipAddress _Source ParentLeafName _SourceUrl ParentVersionString SpouseName StartDate WorkState _Status DecisionStatus HeaderStyleDefinitions LinkDiscussionTitle LinkDiscussionTitleNoMenu Subject Suffix SummaryLinks SummaryLinks2 SystemTask Audience TaskGroup TaskStatus TaskType TelexNumber TemplateId TemplateUrl ThreadIndex ThreadTopic Threading ThreadingControls Thumbnail EncodedAbsThumbnailUrl TimeZone LinkTitle LinkTitleNoMenu SurveyTitle Title ToggleQuotedText TotalWork TrimmedBody TTYTDDNumber DocIcon Purpose _UIVersion UID UniqueId URL URLNoMenu URLwMenu FileRef UserField1 UserField2 UserField3 UserField4 User PublishingVariationGroupID PublishingVariationRelationshipLinkFieldID PublishingAssociatedVariations PublishingVaryByCustom PublishingVaryByHeader PublishingVaryByParam PublishingVaryByRights _UIVersionString _Version VirusStatus EncodedAbsWebImgUrl WebPage Preview WikiField WorkflowAssociation WorkflowInstance WorkflowInstanceID WorkflowItemId WorkflowListId WorkflowName WorkflowTemplate WorkflowVersion WorkspaceLink Workspace XMLTZone WorkZip |
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldtype.aspx
| Member name | Description | |
|---|---|---|
| AllDayEvent | Specifies an all day event. Corresponds to the SPFieldAllDayEvent class and to the AllDayEvent field type that is specified on the Field element. Value = 29. | |
| Attachments | Specifies attachments. Corresponds to the SPFieldAttachments class and to the Attachments field type that is specified on the Field element. Value = 19. | |
| Boolean | Specifies Boolean values that are stored in the database as 1 or 0. Corresponds to the SPFieldBoolean class and to the Boolean field type that is specified on the Field element. Value = 8. | |
| Calculated | Specifies calculated values. Corresponds to the SPFieldCalculated class and to the Calculated field type that is specified on the Field element. Value = 17. | |
| Choice | Specifies a predetermined set of values that can be used to enter data into the field. Corresponds to the SPFieldChoice class and to the Choice field type that is specified on the Field element. Value = 6. | |
| Computed | Specifies an abstract field type that depends on other fields for its content and definition. Corresponds to the SPFieldComputed class and to the Computed field type that is specified on the Field element. Value = 12. | |
| ContentTypeId | Specifies a content type ID. Corresponds to the ContentTypeId field type that is specified on the Field element. Value = 25. | |
| Counter | Specifies an integer used for internal ID fields. Corresponds to the Counter field type that is specified on the Field element. Value = 5. | |
| CrossProjectLink | Specifies a link between projects in a Meetings Workspace site. Corresponds to the SPFieldCrossProjectLink class and to the CrossProjectLink field type that is specified on the Field element. Value = 22. | |
| Currency | Specifies currency values formatted based on a specific locale. Corresponds to the SPFieldCurrency class and to the Currency field type that is specified on the Field element. Value = 10. | |
| DateTime | Specifies date and time values. Corresponds to the SPFieldDateTime class and to the DateTime field type that is specified on the Field element. Value = 4. | |
| Error | Specifies errors. Value = 24. | |
| File | Specifies files. Corresponds to the SPFieldFile class and to the File field type that is specified on the Field element. Value = 18. | |
| GridChoice | Specifies a Choice field for a data sheet. Corresponds to the SPFieldRatingScale class and to the GridChoice field type that is specified on the Field element. Value = 16. | |
| Guid | Specifies GUIDs. Corresponds to the Guid field type that is specified on the Field element. Value = 14. | |
| Integer | Specifies positive or negative integer values. Corresponds to the Integer field type that is specified on the Field element. Value = 1. | |
| Invalid | Not used. Value = 0. | |
| Lookup | Specifies references to values in other lists. Corresponds to the SPFieldLookup class and to the Lookup field type that is specified on the Field element. Value = 7. | |
| MaxItems | Specifies the maximum number of items. Value = 31. | |
| ModStat | Specifies Content Approval status. Corresponds to the SPFieldModStat class and to the ModStat field type that is specified on the Field element. Value = 23. | |
| MultiChoice | Specifies multiple values per list item. Corresponds to the SPFieldMultiChoice class and to the MultiChoice field type that is specified on the Field element. Value = 15. | |
| Note | Specifies a field that can contain multiple lines of text. Corresponds to the SPFieldMultiLineText class and to the Note field type that is specified on the Field element. Value = 3. | |
| Number | Specifies floating point numbers. Corresponds to the SPFieldNumber class and to the Number field type that is specified on the Field element. Value = 9. | |
| PageSeparator | Inserts a page break in a survey list. Corresponds to the SPFieldPageSeparator class and to the PageSeparator field type that is specified on the Field element. Value = 26. | |
| Recurrence | Specifies a field that is used in calendars for recurring events and abstract field type that, like computed fields, depends on other fields for its content and definition. Corresponds to the SPFieldRecurrence class and to the Recurrence field type that is specified on the Field element. Value = 21. | |
| Text | Specifies a single line of text. Corresponds to the SPFieldText class and to the Text field type that is specified on the Field element. Value = 2. | |
| ThreadIndex | Specifies the ID that indicates the relative position of a message within a conversation thread. Corresponds to the ThreadIndex field type that is specified on the Field element. Value = 27. | |
| Threading | Specifies a field that is used in the creation and display of threaded Web discussions. Corresponds to the Threading field type that is specified on the Field element. Value = 13. | |
| URL | Specifies hyperlinks. Corresponds to the SPFieldUrl class and to the URL field type that is specified on the Field element. Value = 11. | |
| User | Specifies users of a SharePoint site. Corresponds to the SPFieldUser class and to the User field type that is specified on the Field element. Value = 20. | |
| WorkflowEventType | Specifies a workflow event type. Corresponds to the WorkflowEventType field type that is specified on the Field element. Value = 30. | |
| WorkflowStatus | Specifies workflow status. Corresponds to the SPFieldWorkflowStatus class and to the WorkflowStatus field type that is specified on the Field element. Value = 28. |
SPWeb site = SPControl.GetContextWeb(Context);
string Msg = "";
SPDocDiscussionCollection discs = site.GetDocDiscussions("Document_Library_Name");
foreach (SPDocDiscussion disc in discs)
{
if (disc.CommentCount > 20)
{
Msg = "The file <A href='" + disc.DocUrl.ToString() + "'>" + disc.DocUrl.ToString() +
"</A> has received " + disc.CommentCount.ToString() + " comments.";
SPUtility.SendEmail(site, false, false, "e-mail_address", "Web Discussion Report", Msg);
}
}

In Microsoft Visual Studio 2008, you can create custom activities that can be consumed in workflows. Creating custom activities lets you encapsulate business logic that applies to different scenarios and that can be used in different workflows. This Microsoft Office Visual How To demonstrates how to create a custom activity to send an e-mail message with an attachment.
First, you must create your custom activity. Then, you can add that to a workflow project and use it to send an e-mail message with an attachment..gif)
Note:
.gif)
