質問

私はSharePoint 2010の初心者です。

リスト内の要素を基準にして指定されたカスタムボタンをクリックしているときに電子メールを送信したいと思います。

選択した要素についての情報のいくつかの情報または「作者」のような情報を電子メールに追加したいと思います。

電子メールを送信するためにこのコードを見つけ、それを.aspxページにコピーしました。このページは、QueryStringによって1つのパラメータを受け取ります。パラメータは、ボタンをクリックするリストの名前を指定する「list_name」です。これがコード内のどこかの場所でSPリストを指定するために使用できると思いますが、まさにどこでどのようにそれを行うのかわかりません。

StringDictionary headers = new StringDictionary();
string bodyTxt = "<b>Test Mail Bold</b>"; //for html mail body, you can send unformatted text too…

headers.Add("to", "mailadressfor_cc@domainname.com");
headers.Add("from", "mailadress_from@domainname.com");
headers.Add("subject", "Richiesta scambio prenotazione");
headers.Add("content-type", "text/html"); //for html mail body

SPUtility.SendEmail(properties.web, headers, bodyTxt);
.

しかし、私の(おそらく愚かな)質問は次のとおりです。

ありがとう!

役に立ちましたか?

解決

Since you have the list name in the query string use it to get SPList as below

SPWeb web = SPContext.Current.Web;
SPList list = web.GetListFromUrl(web.Url + “/Lists/ListName/Forms/AllItems.aspx“);

Then you can get properties from list.

Example:

String listTitle = list.Title;

If you want to get properties from a list item, you can pass item’s ID in the query string too, and get the item as below:

SPListItem item = list.GetItemByID(id);
String itemTitle = item.Title;
String itemFieldValue = item[“fieldname”] == null ? null : item[“fieldname”].ToString();
ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top