×

net 发邮件 net core c

net core 怎么实现邮件发送?如何用C++做directUI的漂亮界面开发

admin admin 发表于2022-05-07 11:27:41 浏览141 评论0

抢沙发发表评论

net core 怎么实现邮件发送

你可以参考一下/*** * @author Sglee* */public class SimpleMail {private static String encode = null;static {if (“\\“.equals(File.separator)) {encode = “GBK“;} else {encode = “UTF-8“;}}/*** 以文本格式发送邮件* * @param mailInfo* @return*/public static boolean sendTextMail(MailInfo mailInfo) {for (int i = 0; i 《 3; i++) {// 判断是否需要身份认证MyAuthenticator authenticator = null;Properties properties = mailInfo.getProperties();if (mailInfo.isValidate()) {// 如果需要身份认证,则创建一个密码验证器authenticator = new MyAuthenticator(mailInfo.getUsername(),mailInfo.getPassword());}// 根据邮件会话属性和密码验证器构造一个发送邮件的sessionSession sendMailSession = Session.getDefaultInstance(properties,authenticator);if (mailInfo.isDebug()) {sendMailSession.setDebug(true);}try {Message mailMessage = new MimeMessage(sendMailSession);// 根据session创建一个邮件消息Address from = new InternetAddress(mailInfo.getFromAddress());// 创建邮件发送者地址mailMessage.setFrom(from);// 设置邮件消息的发送者// Address to = new InternetAddress(mailInfo.getToAddress());//// 创建邮件的接收者地址// mailMessage.setRecipient(Message.RecipientType.TO, to);//// 设置邮件消息的接收者mailMessage.setRecipients(Message.RecipientType.TO,wrapAddress(mailInfo.getToAddress()));// InternetAddress ms = new// InternetAddress(mailInfo.getMsAddress());// mailMessage.setRecipient(Message.RecipientType.BCC, ms); //// 密送人mailMessage.setRecipients(Message.RecipientType.BCC,wrapAddress(mailInfo.getMsAddress()));mailMessage.setSubject(mailInfo.getSubject());// 设置邮件消息的主题mailMessage.setSentDate(new Date());// 设置邮件消息发送的时间// mailMessage.setText(mailInfo.getContent());//设置邮件消息的主要内容// MimeMultipart类是一个容器类,包含MimeBodyPart类型的对象Multipart mainPart = new MimeMultipart();MimeBodyPart messageBodyPart = new MimeBodyPart();// 创建一个包含附件内容的MimeBodyPart// 设置HTML内容messageBodyPart.setContent(mailInfo.getContent(),“text/html; charset=“ + encode);mainPart.addBodyPart(messageBodyPart);// 存在附件String filePaths = mailInfo.getAttachFileNames();if (filePaths != null && filePaths.length 》 0) {for (String filePath : filePaths) {messageBodyPart = new MimeBodyPart();File file = new File(filePath);if (file.exists()) {// 附件存在磁盘中FileDataSource fds = new FileDataSource(file);// 得到数据源messageBodyPart.setDataHandler(new DataHandler(fds));// 得到附件本身并至入BodyPartmessageBodyPart.setFileName(“=?“ + encode + “?B?“+ file.getName());// 得到文件名同样至入BodyPartmainPart.addBodyPart(messageBodyPart);}}}// 将MimeMultipart对象设置为邮件内容mailMessage.setContent(mainPart);Transport.send(mailMessage);// 发送邮件return true;} catch (Exception e) {e.printStackTrace();try {java.util.concurrent.TimeUnit.SECONDS.sleep(5);} catch (Exception e2) {e2.printStackTrace();}}}return false;}/*** 将string包装成EmailAddress* @param mailInfo* @return* @throws AddressException*/private static Address wrapAddress(String adds) throws AddressException {// String adds = mailInfo.getToAddress();if(adds == null || adds.length == 0){return null;}Address to = new Address[adds.length];for(int i = 0;i《adds.length;i++){to[i]=new InternetAddress(adds[i]);}return to;}/*** 以HTML格式发送邮件* * @param mailInfo* @return*/public static boolean sendHtmlMail(MailInfo mailInfo) {for (int i = 0; i 《 3; i++) {

如何用C++做directUI的漂亮界面开发

directui界面库 Duilib是开源的。国内首个开源 的directui 界面库,开放,共享,惠众,共赢,遵循bsd协议,可以免费用于商业项目,目前支持Windows 32 、Window CE、Mobile等平台。Duilib 是一款强大的界面开发工具,可以将用户界面和处理逻辑彻底分离,极大地提高用户界面的开发效率。提供所见即所得的开发工具UIDesigner。使用DirectUI后将使得我们的设计人员彻底解 放,不会受到开发的束缚,可以充分地发挥其设计能力来设计软件界面,并参与到用户界面开发过程中。 Duilib 目前支持Windows 32 、Window CE、Mobile等平台,使用C++开发,遵循BSD协议,可以免费用于商业项目了解更多开源相关,去LUPA社区看看吧。

transaction什么意思中文翻译

transaction英[trænˈzækʃn]美[trænˈsækʃən, -ˈzæk-]n. 交易,业务,事务; 办理,处理; 交易,(一项)事务(一笔); 会议记录,学报(学会等的);全部释义》》[例句]The u. s. government helped finance the transaction.美国政府帮助为这笔交易提供了融资。