We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Send content of document to body of the mail

Hi,

When i click button, document will be Generated and saved in particular place....
After i want to send to mail only content to the body..
How to Send content of document to body of the mail.....?
Please tell me the solution..



Thank you
NARENDRAN
Hi Narendran,

Thanks for your inquiry. Your query is related to Aspose.Email. I am moving this forum thread to Aspose.Email forum. My colleagues from Aspose.Email team will reply you shortly.

Hi Narendran,

You can use Aspose.Email in combination with Aspose.Words API to load MHTML file and send it using the API. Please have a look at the following code sample for your kind reference and let us know if you need further assistance in this regard.

You can also refer to our documentation for further reference in this regard.

Sample Code:

string dataDir = “sourcefolderPathtodocument\”;

// Load a Word document from disk and save to stream as MHTML
Document wordDocument = new Document(dataDir + “Test.doc”);
MemoryStream mhtmlStream = new MemoryStream();
wordDocument.Save(mhtmlStream, SaveFormat.Mhtml);

// Load the MHTML in MailMessage
mhtmlStream.Position = 0;
MailMessage message = MailMessage.Load(mhtmlStream, new MhtmlLoadOptions());
message.Subject = “Sending Invoice in Email”;
message.From = "sender@gmail.com";
message.To = "recipient@gmail.com";

// Save the message in MSG format to disk
message.Save(dataDir + “WordDocAsEmailBody_out.msg”, SaveOptions.DefaultMsgUnicode);

// Send in an email
SmtpClient client = new SmtpClient(“smtp.gmail.com”, 587, "sender@gmail.com", “pwd”);
client.SecurityOptions = SecurityOptions.SSLExplicit;
client.Send(message);

Thanks,

I used this above code in my project

MailMessage message = MailMessage.Load(mhtmlStream, new MhtmlLoadOptions());

Here problems are 'Mail Message does not contain the definition for load’

I don’t have any idea… Pls Help me…

Hi Narendran,


Could you please verify if you have added the Aspose.Email library to your project? If not, please download the latest version from the Product download page. Once done, please add a reference to your project and reference the Aspose.Email.Mail namespace in your project as follow:

using Aspose.Email.Mail;

This will allow your project to recognize the MailMessage object from Aspose.Email API. Please let us know if you need any further assistance in this regard.