on 03-04-2008 7:55 AM
Hi All,
I have a scenario where on Action Submit the uploaded file must send as an e-mail to the given recipient.
I'm able to create the application till uploading file but could not send this as an attachment through e-mail.
Could any one help in this regards.
It is very urgent.
Thanks in advance
ambicasony
Hi All,
Could any help me in other way of sending an email on click on button.
regards
ambicasony
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Just open the below link.
check page 9 and 10 it will clear your problem.
Regards,
Naga
hi
Properties props = System.getProperties();
props.put("mail.smtp.host", "ur smtp server address");
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("give from mail id"));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("to mail id", false));
msg.setSubject("<subject>");
msg.setText("body");
Transport.send(msg);
Regards,
Naga
Hi Sharanya..
I have tried only with partI and used the following code
Properties props = new Properties();
String host = "<IP address>";
props.put("mail.smtp.host",host);
Session session = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("<Email ID>"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(wdContext.currentContextElement().getMailId()));
message.setSubject("Notification");
message.setText("Notification");
Transport.send(message);
But there no errors & the mail is not sent and gives exception as "Client not Authntictaed"
regards
ambicasony
Problem is resolved.
Thanks to all of you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hai ambica,
To use the code i have given you need to import 2 jar files
1.smtp.jar
2.mail.jar
let me know if you face any issues with the code ive given.
Thanks n regards
Sharanya.R
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can download this from http://java.sun.com/products/javamail/downloads/index.html
Regards
Ayyapparaj
hai Ambica,
put this coding inside a method and call that on the on Action property of button.
When give mime body part 2 it ll go as attachment.try this it will work.
try
{
String strSMTPIPAddress ="192.168.100.103";
Properties props;
Session session;
Provider p;
props = System.getProperties();
props.put("mail.smtp.host", strSMTPIPAddress);
session = Session.getDefaultInstance(props, null);
StringBuffer strMailBody = new StringBuffer();
wdThis.createmailbody(strMailBody);
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("<give the email address here>"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("<email address>"));
message.setSubject("<give the subject of mail>");
MimeMultipart mimemultipart = new MimeMultipart();
// //set message content
//this is body content
MimeBodyPart mimebodypart1=new MimeBodyPart();
//This is attachmnent
MimeBodyPart mimebodypart2=new MimeBodyPart();
// mimebodypart1.setText("xxx"); //Attachment
mimebodypart2.setText("<give the content of attachemnt>');
mimemultipart.addBodyPart(mimebodypart1);
mimemultipart.addBodyPart(mimebodypart2);
//message.setText(wdContext.currentContextElement().getSalorder());
message.setContent(mimemultipart);
message.setText(strMailBody.toString());
Transport.send(message);
wdComponentAPI.getMessageManager().reportSuccess("E-mail is sent to sharanya");
}
catch (Exception e)
{
wdComponentAPI.getMessageManager().raiseException("Exception" + e.getMessage(), true);
}
If you have any issues in using this plz let me know.
Thanks n Regards
Sharanya.R
Edited by: Sharanya.R on Mar 4, 2008 9:45 AM
Edited by: Sharanya.R on Mar 4, 2008 9:56 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Pl go through this post
http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeBodyPart.html
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ambica
Refer to this pdf
and the following thread also:
May be it can help
Thanks
Monika
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.