package javamail
import java.io.UnsupportedEncodingException
import javax.activation.DataHandler
import javax.activation.FileDataSource
import javax.mail.MessagingException
import javax.mail.Multipart
import javax.mail.Session
import javax.mail.Transport
import javax.mail.internet.InternetAddress
import javax.mail.internet.MimeBodyPart
import javax.mail.internet.MimeMessage
import javax.mail.internet.MimeMultipart
public class QuickMailAttach {
public static void sendMessage(String smtpHost,String from,String to,String subject,String messageText,String fileName)
throws MessagingException, UnsupportedEncodingException{
//step 1:Configure the mail session
System.out.println("Configuring mail session for:"+smtpHost)
SmtpAuth sa=new SmtpAuth()
sa.getuserinfo("test","378914")
sa.getPasswordAuthentication()
java.util.Properties props=new java.util.Properties()
props.put("mail.smtp.auth","true")
props.put("mail.smtp.host",smtpHost)
Session mailSession=Session.getDefaultInstance(props,sa)
//Step2:Construct the message
System.out.println("Constructing message -from="+from+" to="+to)
InternetAddress fromAddress=new InternetAddress(from)
InternetAddress toAddress=new InternetAddress(to)
MimeMessage testMessage=new MimeMessage(mailSession)
testMessage.setFrom(fromAddress)
testMessage.addRecipient(javax.mail.Message.RecipientType.TO,toAddress)
testMessage.setSentDate(new java.util.Date())
testMessage.setSubject(subject)
//Step3:create a body part to hold the "text" portion of the message
System.out.println("Constructing 'text' body part")
MimeBodyPart textBodyPart=new MimeBodyPart()
textBodyPart.setText(messageText)
//Step 4:Create a body part to hold the "file" portion of the message
System.out.println("Attaching 'file' body part:"+fileName)
MimeBodyPart fileBodyPart=new MimeBodyPart()
FileDataSource fds=new FileDataSource(fileName)
fileBodyPart.setDataHandler(new DataHandler(fds))
fileBodyPart.setFileName(new String(fds.getName().getBytes(),"iso-8859-1"))
System.out.println("Finished attaching file")
MimeBodyPart fileBodyPart2=new MimeBodyPart()
FileDataSource fds2=new FileDataSource("D:\\test\\test.doc")
fileBodyPart2.setDataHandler(new DataHandler(fds2))
fileBodyPart2.setFileName(new String(fds2.getName().getBytes(),"iso-8859-1"))
System.out.println("Finished attaching file")
//Step 5:Create a Multipart/container and add the parts
Multipart container=new MimeMultipart()
container.addBodyPart(textBodyPart)
container.addBodyPart(fileBodyPart)
container.addBodyPart(fileBodyPart2)
//Step 6:Add the Multipart to the actual messge
testMessage.setContent(container)
System.out.println("Messge constructed")
//Step 7:Now send the message
Transport.send(testMessage)
System.out.println("Message sent.")
}
public static void main(String[] args) throws Exception{
String smtpHost="smtp.163.com"
String from="test@163.com"
String to="test@163.com"
String filename="D:\\test\\test.doc"
String subject="Test message"
StringBuffer theMessage=new StringBuffer()
theMessage.append("ddddhello22,\n\n")
theMessage.append("Hope all is well on you end.\n")
theMessage.append("Cheers")
try{
QuickMailAttach.sendMessage(smtpHost,from,to,subject,theMessage.toString(),filename)
}catch(javax.mail.MessagingException exc){
exc.printStackTrace()
}
}
static class SmtpAuth extends javax.mail.Authenticator {
private String user,password
public void getuserinfo(String getuser,String getpassword){
user = getuser
password = getpassword
}
protected javax.mail.PasswordAuthentication getPasswordAuthentication(){
return new javax.mail.PasswordAuthentication(user,password)
}
}
}
微软用户在绑定邮箱邮件内获取microsoft验证电子邮件输入代码,本答案使用百度浏览器进行演示。以下为详细步骤说明:
工具/原料:华硕天选3、Windows 11、百度浏览器8.7。
1、打开验证邮箱
使用百度浏览器打开绑定的验证邮箱。
2、点击收件箱
点击邮箱界面的收件箱。
3、打开输入代码邮件
在收件箱中双击打开microsoft验证电子输入代码邮件。
1,使用桌面邮件程序如outlook,foxmail可以选择html模板,发送的邮件均会是html格式的。2,使用gmail,126等邮箱其本生提供文本格式化,而格式化即使为文字添加代码只是这些代码你看不到而已,你所看到的是代码执行以后的结果,因此我估计如果你直接自行编写代码在里面也是可以格式化的,如果是这样你可以用网页编辑工具实现设计好你的简历页面然后粘贴进去即可。
3,2方法没有试过,如果不行可以采用以下方法,将简历网页做好,然后申请一个免费空间放上去,然后在给公司的邮件中写上这个网页的连接地址。
制作HTML网页可以用dreamweaver软件开发工具,对于新手来说是在适合不过,因为有很多标签和属性给与提示。只要你学会了html、DIV+CSS这两大块,完成一个静态的网站可以说搓搓有余了。如果你还想要将网站做的更加的华丽,你要需学习JS等知识。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)