Monday 15 July 2013

c# - Sending a Word Document as an email -


Microsoft Word document in 2007, it is possible to send as an e-mail body; What is a way to use the 'Send Mail To Recipients' option in text, image, and format C #? And if it is possible how would I go about doing it? thank you in advanced!

To do this you need to write a Microsoft Word addin for basic on the Czech Microsoft site: < / P>

And you can do something like below to solve your xestation. The code will send the mail when you save the document. With a word Edin you have many incidents, which you can do and make your own content. Or if you want to send a mail by clicking on a button, you can add your own button.

  zero Addin_startap (object sender, System. Aventarj e) {this.Application.DocumentBeforeSave + = new Microsoft.Office.Interop.Word.ApplicationEvents4_DocumentBeforeSaveEventHandler (DocumentSave); } Void document Save (Word. Document doc, Refu Balls Test, Refu Balls Test 2) {if (Doc Word. Document) {SendMailWithAttachment (doc); }} Public void SendMailWithAttachment (Word.Document document) {SmtpClient smtpClient = new SmtpClient (); Network credentials Basic credentials = New network credentials (MailConstup user's name, MailConstration password); Mail message message = new mailmasonry (); Address from mail address = new mail address (mailcon. Username); // Host setup, extend timeout up to 5 minutes smtpClient.Host = MailConst.SmtpServer; SmtpClient.UseDefaultCredentials = false; SmtpClient.Credentials = Basic credentials; SmtpClient.Timeout = (60 * 5 * 1000); message. From = address; message. Subject = topic; Message.IsBodyHtml = false; message. Body = body; Message.To.Add (recipient); Var Atacmentfilnam = Doctorkfulnam if (Atacmentfilnam! = NULL) {attachment attachment = new attachment (Anulgnkfilmen name, Meediatippnam. Aplikeshnkoktet); Content dispute nature = attachment Content disposition; Nature CreationDate = File.GetCreationTime (AttachmentFilename); Nature Monetization date = file. Getlastriteime (Attachfillenam); Nature Reddet = file Gettest Asset Time (AttachmentFilename); Disposition.FileName = Path. GetFileName (AttachfillName); Nature = size = new file info (attachment filename). Lamps; Disposition.DispositionType = DispositionTypeNames.Attachment; Message.Attachments.Add (attachment); } SmtpClient.Send (message); }    

No comments:

Post a Comment