Aspose.Email全面支持AMP电子邮件管理!体验更快的消息下载速度
程序员文章站
2023-12-31 21:16:52
AMP(加速的移动页面)是Google的开发人员软件包,它允许开发负载更快的轻量级系统。AMP是由HTML,JavaScript和CSS组成的框架,它们是为用户提供Web内容优先格式的标准。 Aspose.Email for .NET是一套全面的电子邮件处理API,可用于构建跨平台应用程序。近期的更 ......
amp(加速的移动页面)是google的开发人员软件包,它允许开发负载更快的轻量级系统。amp是由html,javascript和css组成的框架,它们是为用户提供web内容优先格式的标准。
aspose.email for .net是一套全面的电子邮件处理api,可用于构建跨平台应用程序。近期的更新中,aspose.email支持amp html电子邮件。通过将google的amp项目的一部分用于电子邮件,aspose.email目前拥有大量要使用的组件列表,这种方法的主要优点是提高了消息下载速度,这对大多数用户来说至关重要。
除了速度快之外,amp电子邮件还可以在电子邮件客户端内部呈现完全交互式的电子邮件,客户可以直接与电子邮件进行交互,例如填写表格或回复调查而无需离开电子邮件客户。
下面我们来了解一下使用aspose.email api创建,保存和更新amp电子邮件的过程。
string datadir = runexamples.getdatadir_output(); ampmessage msg = new ampmessage(); msg.htmlbody = "hello amp"; //add ampanim component ampanim anim = new ampanim(800, 400); anim.src = "https://placekitten.com/800/400"; anim.alt = "test alt"; anim.attribution = "the go gopher was designed by reneee french"; anim.attributes.layout = layouttype.responsive; anim.fallback = "offline"; msg.addampcomponent(anim); //add ampimage component ampimage img = new ampimage(800, 400); img.src = "https://placekitten.com/800/400"; img.alt = "test alt"; img.attributes.layout = layouttype.responsive; msg.addampcomponent(img); //add ampcarousel component ampcarousel car = new ampcarousel(800, 400); img = new ampimage(800, 400); img.src = "https://amp.dev/static/img/docs/tutorials/firstemail/photo_by_caleb_woods.jpg"; img.alt = "test 2 alt"; img.attributes.layout = layouttype.fixed; car.images.add(img); img = new ampimage(800, 400); img.src = "https://placekitten.com/800/400"; img.alt = "test alt"; img.attributes.layout = layouttype.responsive; car.images.add(img); img = new ampimage(800, 400); img.src = "https://amp.dev/static/img/docs/tutorials/firstemail/photo_by_craig_mclaclan.jpg"; img.alt = "test 3 alt"; img.attributes.layout = layouttype.fill; car.images.add(img); msg.addampcomponent(car); //add ampfittext component ampfittext txt = new ampfittext("lorem ipsum dolor sit amet, has nisl nihil convenire et, vim at aeque inermis reprehendunt."); txt.attributes.width = 600; txt.attributes.height = 300; txt.attributes.layout = layouttype.responsive; txt.minfontsize = 8; txt.maxfontsize = 16; txt.value = "lorem ipsum dolor sit amet, has nisl nihil convenire et, vim at aeque inermis reprehendunt."; msg.addampcomponent(txt); //add ampaccordion component ampaccordion acc = new ampaccordion(); acc.expandsinglesection = true; section sec = new section(); sec.header = new sectionheader(sectionheadertype.h2, "section 1"); sec.value = new sectionvalue("content in section 1."); acc.sections.add(sec); sec = new section(); sec.header = new sectionheader(sectionheadertype.h2, "section 2"); sec.value = new sectionvalue("content in section 2."); acc.sections.add(sec); img = new ampimage(800, 400); img.src = "https://placekitten.com/800/400"; img.alt = "test alt"; img.attributes.layout = layouttype.responsive; sec = new section(); sec.header = new sectionheader(sectionheadertype.h2, "section 3"); sec.value = new sectionvalue(img); acc.sections.add(sec); msg.addampcomponent(acc); //add ampform component ampform form = new ampform(); form.method = formmethod.post; form.actionxhr = "https://example.com/subscribe"; form.target = formtarget.top; formfield field = new formfield("name:", "text"); field.name = "name"; field.isrequired = true; form.fieldset.add(field); field = new formfield("email:", "email"); field.name = "email"; field.isrequired = true; form.fieldset.add(field); field = new formfield(); field.inputtype = "submit"; field.value = "subscribe"; form.fieldset.add(field); msg.addampcomponent(form); msg.save(datadir + "amptest_1.eml"); mailmessage savedmsg = mailmessage.load(datadir + "amptest_1.eml"); ampmessage ampmsg = savedmsg as ampmessage; if (ampmsg != null) { datetime dt = new datetime(2019, 9, 27, 1, 1, 1, datetimekind.utc); amptimeago time = new amptimeago(dt); time.attributes.width = 600; time.attributes.height = 300; time.attributes.layout = layouttype.fixed; time.locale = "en"; time.cutoff = 600; ampmsg.addampcomponent(time); ampmsg.save(datadir + "amptest_2.eml"); }
还想要更多吗?如果您有任何疑问或需求,请随时加入aspose技术交流群(642018183)。