Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My firewall is blocking kusek's link but I'm sure that's the place to go. Coincidentally I was just developing this yesterday so can share the highlights.</p> <p><strong>Feature file</strong></p> <p>This <a href="http://msdn.microsoft.com/en-us/library/ms465980.aspx" rel="nofollow noreferrer">custom action feature</a> adds a menu option to all document libraries. Adjust the content type if you need to restrict this to only certain documents.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt; &lt;CustomAction Id="OpenInMailClient" RegistrationType="ContentType" RegistrationId="0x0101" Location="EditControlBlock" Sequence="500" ImageUrl="/_layouts/images/iceml.gif" Title="Send As Attachment"&gt; &lt;UrlAction Url="~site/_layouts/Custom/SendMail.aspx?ItemId={ItemId}&amp;amp;ListId={ListId}" /&gt; &lt;/CustomAction&gt; &lt;/Elements&gt; </code></pre> <p><strong>Application page</strong></p> <p>I developed an application page used Karine Bosch's excellent <a href="http://karinebosch.wordpress.com/sharepoint-controls/" rel="nofollow noreferrer">reference of SharePoint controls</a> to design and create the application page so it looked nice and 'SharePointy'. I also used a rich HTML box so the user could enter rich text into the body which seems to be working nicely.</p> <p><strong>Sending the message</strong></p> <p>This is pretty standard .NET. The only semi-cool part is using the outgoing mail server set in SharePoint to send the message. Note that there is a method to send mail in the SharePoint API but it doesn't seem to support attachments and I couldn't see the benefit of using it.</p> <pre><code>// Prepare message MailMessage message = new MailMessage { Subject = txtSubject.Text, Body = txtBody.Text, IsBodyHtml = true, From = new MailAddress(txtFromAddress.Text) }; message.To.Add(txtToAddress.Text); if (!String.IsNullOrEmpty(txtCCAddress.Text)) message.CC.Add(txtCCAddress.Text); message.Bcc.Add(txtBCCAddress.Text); // Prepare attachment Stream stream = chosenItem.File.OpenBinaryStream(); Attachment attachment = new Attachment(stream, chosenItem.Name, "application/octet-stream"); message.Attachments.Add(attachment); // Send message string server = SPContext.Current.Site.WebApplication.OutboundMailServiceInstance.Server.Address; SmtpClient client = new SmtpClient(server); client.Send(message); // Clean up stream.Dispose(); attachment.Dispose(); message.Dispose(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload