2009-07-16 29 views

回答

1

我的防火牆阻止了kusek的鏈接,但我相信這是一個好去處。巧合的是我昨天剛剛開發這個,所以可以分享亮點。

特性文件

custom action feature增加了一個菜單選項,所有文檔庫。如果您需要將其限制爲僅限某些文檔,請調整內容類型。

<?xml version="1.0" encoding="utf-8" ?> 
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 
    <CustomAction 
     Id="OpenInMailClient" 
     RegistrationType="ContentType" 
     RegistrationId="0x0101" 
     Location="EditControlBlock" 
     Sequence="500" 
     ImageUrl="/_layouts/images/iceml.gif" 
     Title="Send As Attachment"> 
     <UrlAction Url="~site/_layouts/Custom/SendMail.aspx?ItemId={ItemId}&amp;ListId={ListId}" /> 
    </CustomAction> 
</Elements> 

應用頁面

我開發使用的應用程序頁面卡林納博世的優秀reference of SharePoint controls設計和創建應用程序頁面,以便它看起來不錯,「SharePointy」。我還使用了一個豐富的HTML框,以便用戶可以將豐富的文本輸入到似乎正在工作的正文中。

發送消息

這是相當標準的.NET。唯一的半酷部分是使用SharePoint中設置的發送郵件服務器來發送郵件。請注意,有一種方法可以在SharePoint API中發送郵件,但它似乎不支持附件,我無法看到使用它的好處。

// 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(); 
1

您可以使用自定義操作和佈局頁面來完成此操作。有關更多詳情,請參閱this鏈接。格式化鏈接是不整潔的,但這是你需要遵循的方法。您可能需要做的另一件事是以某種方式將電子郵件ID設置爲在上述文章中發送的電子郵件ID,以便他們從用戶那裏獲取電子郵件。你可能需要發送一個以及querystring參數。

相關問題