Quick way to send emails from PeopleCode

本文介绍了在PeopleCode中发送邮件的两种方式:使用SendMail命令和EmailClass。通过具体的代码示例,展示了如何设置收件人、抄送、密送、主题、正文和附件,以及如何检查邮件发送状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Here's a quick way to send an email message from within peoplecode. You can also send attachments along with your email message. Simply use the PeopleCode command SendMail to send an email message from a PeopleSoft page. You can simply copy this code and change the values with yours and you'll be sending mail in no time. This is very useful code to use within Application Engine.

 

REM ****************************************;
REM SEND MAIL MESSAGE;
REM ****************************************;

&FLAGS = 0;
&TO = "you@youremailaddress.com";
&CC = "";
&BCC = "me@myemailaddress.com";
&SUBJECT = "Sample Subject"
&TEXT = "This is a sample mail message."
&FILES = "C:\DATA\YOURFILE.TXT"

&RETURN_CODE = SendMail(&FLAGS, &TO, &CC, &BCC, &SUBJECT, &TEXT, &FILES, &TITLES);

If Not (&RETURNCODE = 0) Then
rem WinMessage("Here is the Return Code = " / &RETURNCODE);
End-If;

 

Another way to send email with email class.

import PT_MCF_MAIL:*;

 

/*-- Create an email object by setting individual parameters ---*/

Local PT_MCF_MAIL:MCFOutboundEmail &eMail = create PT_MCF_MAIL:MCFOutboundEmail();

Local string &emailaddress;

Local string &emailsentaddress;

Local string &text;

&emailaddress = "gyu@ataway.com";

&emailsentaddress = "98_degree@163.com";

&text = "text for test";

&eMail.Recipients = &emailaddress; /* comma separated list of email addresses */

&eMail.CC = &emailaddress; /* comma separated list of email addresses */

&eMail.BCC = &emailaddress; /* comma separated list of email addresses */

&eMail.From = &emailsentaddress; /* from email address */

&eMail.ReplyTo = &emailsentaddress; /* in case the reply is to be sent to a different email address */

&eMail.Sender = &emailsentaddress; /* If different from the "from" address */

 

&eMail.Subject = &text; /* email subject line */

&eMail.Text = &text; /* email body text */

 

/*-- Override the default SMTP parameters specified in app server configuration file ----*/

&eMail.SMTPServer = "smtp.163.com";

&eMail.SMTPPort = 25; /*-- Usually this is 25 by default */

Local integer &resp = &eMail.Send();

/* Now check the &resp for the result */

Local boolean &done;

Evaluate &resp

When %ObEmail_Delivered

   /* every thing ok */

   &done = True;

   Break;

  

When %ObEmail_NotDelivered

   /*-- Check &email.InvalidAddresses, &email.ValidSentAddresses

and &email.ValidUnsentAddresses */

   &done = False;

   Break;

  

When %ObEmail_PartiallyDelivered

   /* Check &email.InvalidAddresses, &email.ValidSentAddresses

and &email.ValidUnsentAddresses; */

   &done = True;

   Break;

  

When %ObEmail_FailedBeforeSending

   /* Get the Message Set Number, message number;

Or just get the formatted messages from &email.ErrorDescription,

&email.ErrorDetails;*/

  

   &done = False;

   Break;

End-Evaluate;

For attachment, use the code below:

Local PT_MCF_MAIL:MCFBodyPart

&attach2 = create PT_MCF_MAIL:MCFBodyPart();
&attach2.SetAttachmentContent("///file:C:/User/Documentum/XML%20Applications/proddoc/peoplebook_upc/peoplebook_upc.dtd",%FilePath_Absolute, "Sample.jpg", "Sample", "", "");

 

转载于:https://www.cnblogs.com/GoDevil/archive/2009/01/09/1372662.html

内容概要:本文详细解析了2014年全国大学生电子设计竞赛C题——智能小车设计的全过程。文章首先介绍了该竞赛的背景及其重要意义,指出其不仅是对学生电子设计能力的考验,还对学生的学术成长和职业发展有深远影响。随后,文章深入剖析了C题的具体要求,包括小车的起跑、行驶、超车等复杂动作,强调了硬件(如控制模块、电源模块、车体、电机模块)和软件(如信号检测与控制、两车通信、节能技术、程序设计)方面的关键技术和实现方法。最后,文章分享了测试与优化的经验,并总结了团队合作、知识储备和实践能力的重要性,展望了电子设计领域的发展趋势。 适合人群:电子信息类专业学生、电子设计爱好者及希望深入了解智能小车设计的技术人员。 使用场景及目标:①了解全国大学生电子设计竞赛的背景和重要性;②掌握智能小车设计的硬件选型和软件编程技巧;③学习信号检测与控制、两车通信、节能技术等关键技术;④借鉴测试与优化的经验,提升实际动手能力和解决问题的能力。 阅读建议:本文内容详实,涵盖了从理论到实践的各个方面。建议读者在阅读过程中结合实际操作,逐步理解和掌握智能小车设计的各项技术和原理,特别是对硬件电路设计和软件编程部分,可以通过搭建实验平台进行实践,加深理解。同时,关注文中提到的测试与优化策略,有助于提高实际项目的成功率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值