This post has been moved to a more appropriate forum.
Sorry for that, thank you
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
The Java API for sending email is called JavaMail. The http://faq.javaranch.com/java/JavaEnterpriseEditionFaq has some links to introductions and other material about it. Note that you'll need an email server to use it (or use a library like Aspirin that can send email w/o a mail server).
Ulf Dittmer wrote:The Java API for sending email is called JavaMail. The http://faq.javaranch.com/java/JavaEnterpriseEditionFaq has some links to introductions and other material about it. Note that you'll need an email server to use it (or use a library like Aspirin that can send email w/o a mail server).
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++)
{
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);
// Optional : You can also set your custom headers in the Email if you Want
msg.addHeader("MyHeaderName", "Write here the email header");
// Setting the Subject and Content Type
msg.setSubject(subject);
/*msg.setContent(message, "text/plain");*/
// Create a message part to represent the body text
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(message);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart);
//msg.setContent(message, "text/plain");
Transport.send(msg);
}
mihira
Mahesh Lohi
Ranch Hand
Joined: Jun 22, 2009
Posts: 150
posted
0
mih ira wrote: This is the sample code for your request
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++)
{
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);
// Optional : You can also set your custom headers in the Email if you Want
msg.addHeader("MyHeaderName", "Write here the email header");
// Setting the Subject and Content Type
msg.setSubject(subject);
/*msg.setContent(message, "text/plain");*/
// Create a message part to represent the body text
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(message);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart);
//msg.setContent(message, "text/plain");
Transport.send(msg);
}
Thank you for the reply
"email server ip address"
What is the ip
Thank you in advance
mih ira
Greenhorn
Joined: Sep 30, 2008
Posts: 10
posted
0
It is the mail server IP.
You have to give the mail server IP address and open the ports for email send.
Mahesh Lohi
Ranch Hand
Joined: Jun 22, 2009
Posts: 150
posted
0
mih ira wrote:It is the mail server IP.
You have to give the mail server IP address and open the ports for email send.
Thank you for the quick reply.
I am new to this technology. Please explain further or if possible the link where I can find the answer. Hope you dont mind