Pdf创建并作为邮件附件发送 [英] Pdf creation and send as an mail attachment

查看:121
本文介绍了Pdf创建并作为邮件附件发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个输入表单,我已填写,现在提交我想在输入表格中发送详细信息作为pdf邮件作为附件





代码:





[授权]

[HttpGet]

public ActionResult InCountryForm(string ac)

{

DisplayLnd dn = new DisplayLnd();

DbAccess da = new DbAccess();

dn.Lnd_Program = new LndFeedback.Models.lnd_prgm();

dn.Lnd_Program.create_date = DateTime.Now;

dn.Lnd_Program.from_date = DateTime.Now;

dn.Lnd_Program.till_date = DateTime.Now;

dn.Lnd_Program.create_by = User.Identity.Name;

dn.Lnd_Program.prgm_id = ac;

dn.Lnd_Program.prgm_type =IN COUNTRY;

dn.Lnd_Program.country_id = 72 ;

dn.Lnd_Program.no_of_attendees =0;

dn.txt = DateTime.Now.ToString(dddd,dd MMMM yyyy);

dn.nwTm = DateTime .Now.ToShortTimeString();

//dn.Lnd_Program.from_date = dn.Lnd_Program.from_date;

//dn.Lnd_Program.till_date = dn.Lnd_Program.till_date;

dn.ListAgency = da.FindAgencyList();

dn.ListState = da.FindStates();

返回查看(dn);

}



[HttpPost]

[ValidateAntiForgeryToken]

public ActionResult InCountryForm(DisplayLnd dn)

{



DbAccess da = new DbAccess();

lnd_prgm Lnd_Program = dn.Lnd_Program;



DisplayLnd对象在GET方法中填写了所有细节

我想在post方法中创建pdf,然后将其邮寄给人。



我尝试过:



创建的pdf不应存储在任何服务器中。所以基本上是飞行pdf然后邮寄它作为附件。

i have an input form which i have filled , now on the submission i want to send the details in the input form as a pdf in mail as an attachment


Code:


[Authorize]
[HttpGet]
public ActionResult InCountryForm(string ac)
{
DisplayLnd dn = new DisplayLnd();
DbAccess da = new DbAccess();
dn.Lnd_Program = new LndFeedback.Models.lnd_prgm();
dn.Lnd_Program.create_date = DateTime.Now;
dn.Lnd_Program.from_date = DateTime.Now;
dn.Lnd_Program.till_date = DateTime.Now;
dn.Lnd_Program.create_by = User.Identity.Name;
dn.Lnd_Program.prgm_id = ac;
dn.Lnd_Program.prgm_type = "IN COUNTRY";
dn.Lnd_Program.country_id = 72;
dn.Lnd_Program.no_of_attendees = "0";
dn.txt = DateTime.Now.ToString("dddd, dd MMMM yyyy");
dn.nwTm = DateTime.Now.ToShortTimeString();
//dn.Lnd_Program.from_date = dn.Lnd_Program.from_date;
//dn.Lnd_Program.till_date = dn.Lnd_Program.till_date;
dn.ListAgency = da.FindAgencyList();
dn.ListState = da.FindStates();
return View(dn);
}

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult InCountryForm(DisplayLnd dn)
{

DbAccess da = new DbAccess();
lnd_prgm Lnd_Program = dn.Lnd_Program;

The DisplayLnd object has all the details filled in the GET Method
i want to create the pdf in the post method and then mail it toa person.

What I have tried:

the pdf created should not be stored in any server. So basically on th fly pdf and then mail it as an attachment.

推荐答案

可能最好的方法是使用模板PDF,并使用Acrobat SDK填写该模板的空白。完成后,您可以从内存中取出PDF对象并将其直接编码到电子邮件正文中。



我个人至少会暂时保存PDF然后使用附件方法将PDF放入电子邮件中。
Probably the best way to do this would be to have a Template PDF, and using the Acrobat SDK fill in the blanks for that template. Once you have that completed, you could take the PDF object from memory and encode it directly into the email body.

I personally would save the PDF at least temporarily and then use the attachment methods to put the PDF into the email.


这篇关于Pdf创建并作为邮件附件发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆