سؤال

حصلت على كائن MailMessage System.net.mail وتريد حفظه إلى توثيق بعد إرساله. يحتوي هذا الكائن على المرسل، إلى، CC، HTML للجسم والمرفقات.

كيف يمكنني حفظه إلى المستندات؟

وجدت بعض الطرق لاستخدام "حفظ" - methodes ولكن كلها فقط تدعم المسار المحلي مثل هذا على codeplex .

في النهاية أريد فقط .ML أو .msg في المجلد الخاص بي.

بفضل إجابتك حصلت على غرامة العمل: giveacodicetagpre.

هل كانت مفيدة؟

المحلول

Judging from the link you reported, the Save method calls a FileStream object. Being a stream, the FileStream can be replaced by a MemoryStream.

// Create MemoryStream object
MemoryStream stream = new MemoryStream();

// Get reflection info for MailWriter contructor
// [omitted for brevity]

// Construct MailWriter object with our MemoryStream
object _mailWriter = _mailWriterContructor.Invoke(new object[] { stream });

Then, it is just a matter of saving this stream to your document set, like this:

SPFolder ds = web.GetFolder("http://server/documentsetname");
byte[] data = new byte[stream.Length];
stream.Read(data, 0, (int)stream.Length); //make sure this is reliable, otherwise find other ways to convert to a byte array
ds.Files.Add("http://server/shared%20documents/documentsetname/your.msg", data);
ds.Update();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top