Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is there a way to change the behavior of the "send to"-drop-down in a DL from "E-Mail a link" to "E-Mail as attachment"?

share|improve this question
    
SmtpClient is not available from a sandboxed solution: social.technet.microsoft.com/Forums/en-US/… SPUtility.SendEmail() doesn't allow attachments either. @Flash265 did you find an appropriate workaround? –  SilverlightFox Dec 9 '11 at 17:05
add comment

2 Answers 2

up vote 4 down vote accepted

If you want to send a document as an attachment, you will need to write custom code. Use a feature to create a custom action that adds the "Send as attachment" link to the ECM.

<UrlAction Url="~site/_layouts/MyApp/MyCustomPage.aspx?ItemId={ItemId}&amp;ListId={ListId}" />

Clicking this menu item navigates to a custom application page where the user enters the email address/subject/email-body. The code-behind constructs the email and creates the attachment based on the current item and then sends the email.

using System.Net.Mail;

// get current list and item from query string
string listId = Request.QueryString["ListId"];
SPList list = this.Web.Lists[new Guid(listId)];
string itemId = Request.QueryString["ItemId"];
SPListItem item = list.Items.GetItemById(Convert.ToInt32(itemId));

// get from, to, subject, and body from your aspx page and use to construct mail message
MailMessage msg = new MailMessage(from, to, subject, body);

// create attachment from current item
Stream ms = new MemoryStream(item.File.OpenBinary());
msg.Attachments.Add(new Attachment(ms, item.File.Name));

// send email
SmtpClient smtp = new SmtpClient("yourSMTPserver");
smtp.Send(msg);
share|improve this answer
    
Thank your for your answer Laurie. I will try that out asap. Does this work as a sandbox solution? I don't have farm access in the enviroment where I need it. –  Flash265 Jun 15 '11 at 10:01
add comment

Try to use custom WF Activity : "SharePoint 2010 - Send Email With Attachment" : http://sharepointstuff.codeplex.com/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.