Hey Felipe,

  Here is what you need to do:

 Client Side :

   SendEmail.java (Entrypoint or a Popup) - A very basic design would be of
a TextArea / RichTextArea where you can have the body of the email written.
Then you can provide a "Send" Button. On the click of the send button,
create an object of the Async class and call the SendEmail function with the
String parameter.

   SendEmailService.java - A simple method with a String parameter,
something like this.
    public void SendEmail(String body) throws Exception.

   SendEmailServiceAsync.java - A simple method again with a String
parameter this way:
    public void SendEmail(AsyncCallback<Void> callback).

Server Side:

   SendEmailServiceImpl.java - Implement the function I had sent earlier and
you shud be able to send the email with that successfully.

 Note : If you want to send other parameters like username etc from the
client side, then I would advise using a Vo rather than a String parameter
alone.

 Hope this helps..

Let me know if u need any other help. No matter how silly.. (I have asked
sillier doubts when I had started understanding GWT, he he)

Regards,
Abhi




On Tue, May 11, 2010 at 10:32 PM, Felipe Guarda <felip...@gmail.com> wrote:

> Abhi, you could best describe what must be put on every piece of code?
> You sent me a piece of code that must remain in the Class
> EmailServiceImpl server.side. My doubts are now, I need to create some
> kind of interface EmailService and EmailServiceAsync?
> In cliente.side.code how do I send the e-mail? Should I instantiate
> that class?
> Sorry for the stupid questions, I am now getting this world java /
> gwt.
>
> thanks,
>
> Felipe
>
> On May 11, 11:48 am, abhiram wuntakal <abhir...@gmail.com> wrote:
> > Hi Felipe,
> >
> > RPC implementation would be simple. Just write an ordinary
> > RemoteServiceServlet and write a function to pass a String parameter (or
> a
> > Vo) with the emailBody to the ServiceImpl code. From ServiceImpl, you can
> > use the code below to send the email.
> >
> > Let me know if this answers your question.
> >
> > Regards,
> > Abhi
> >
> >
> >
> >
> >
> > On Tue, May 11, 2010 at 6:48 PM, Felipe Guarda <felip...@gmail.com>
> wrote:
> > > but what about the implementation of the RPC, you could help me?
> > > thanks
> >
> > > On May 10, 2:06 am, abhiram wuntakal <abhir...@gmail.com> wrote:
> > > > Hi Felipe,
> >
> > > >   This block of code would help you send an email from the
> application.
> > > The
> > > > trick basically is to get the textual data from the client side and
> pass
> > > it
> > > > to the server side and then use this piece of code to send the email.
> > > This
> > > > is actually with the file attachment feature even.
> >
> > > >   Initially, you need to have a few variables declared for the
> username,
> > > > password, SMTP etc...
> >
> > > > private static String SMTP_HOST_NAME = "abc-abc.abc.com";
> > > >     private static String SMTP_AUTH_USER = "a...@abc.com";
> > > >     private static String SMTP_AUTH_PWD = "abcpassword";
> > > >     private static final String emailMsgTxt = "Sample Message -
> Testing
> > > the
> > > > email application";
> > > >     private static final String emailSubjectTxt = "Sample Mail";
> > > >     private static String emailFromAddress = "ab...@abcde.com";
> > > >     private static final String[] emailList = new String[100];
> > > >     String fileAttachment = SRCFOLDER + "sample.pdf";
> >
> > > >   public void sendEmail(EmailDetailsVo emailVo) {
> > > >         emailList[0] = emailVo.getEmailRecipient();
> > > >         Writer output = null;
> > > >         String text = "sample Text";
> > > >         OutputStream file;
> > > >         System.out.println("Inside send email2");
> >
> > > >         fileAttachment = SRCFOLDER + "sample.pdf";
> >
> > > >         try {
> > > >             file = new FileOutputStream(
> > > >                     new File(
> > > >                             SRCFOLDER + "sample.pdf"));
> >
> > > >             Document document = new Document();
> > > >             try {
> > > >                 PdfWriter.getInstance(document, file);
> > > >                 document.open();
> > > >                 document.add(new
> Paragraph(String_Body_Of_The_Email));
> >
> > > >             } catch (DocumentException e) {
> > > >                 // TODO Auto-generated catch block
> > > >                 e.printStackTrace();
> > > >             }
> >
> > > >             document.close();
> > > >             try {
> > > >                 file.close();
> > > >             } catch (IOException e) {
> > > >                 // TODO Auto-generated catch block
> > > >                 e.printStackTrace();
> > > >             }
> >
> > > >         } catch (FileNotFoundException e1) {
> > > >             // TODO Auto-generated catch block
> > > >             e1.printStackTrace();
> > > >         }
> >
> > > >         Properties props = new Properties();
> > > >         props.put("mail.transport.protocol", "smtp");
> > > >         props.put("mail.smtp.starttls.enable", "true");
> > > >         props.put("mail.smtp.host", SMTP_HOST_NAME);
> > > >         props.put("mail.smtp.auth", "true");
> >
> > > >         Authenticator auth = new SMTPAuthenticator();
> > > >         Session session = Session.getDefaultInstance(props, auth);
> > > >         MimeMessage message1 = new MimeMessage(session);
> > > >         try {
> > > >             message1.setFrom(new InternetAddress(emailFromAddress));
> > > >             message1.addRecipient(Message.RecipientType.TO,
> > > >                     new InternetAddress(emailList[0]));
> > > >             message1.setSubject(emailVo.getEmailSubject());
> > > >             message1.addRecipient(Message.RecipientType.CC,
> > > >                     new
> InternetAddress(emailVo.getCcEmailAddress()));
> > > >             // create the message part
> > > >             MimeBodyPart messageBodyPart = new MimeBodyPart();
> >
> > > >             // fill message
> > > >             messageBodyPart.setText(emailVo.getEmailBody());
> >
> > > >             Multipart multipart = new MimeMultipart();
> > > >             multipart.addBodyPart(messageBodyPart);
> > > >             messageBodyPart = new MimeBodyPart();
> >
> > > >             DataSource source = new FileDataSource(fileAttachment);
> > > >             messageBodyPart.setDataHandler(new DataHandler(source));
> > > >             messageBodyPart.setFileName("MainPdf.pdf");
> > > >             multipart.addBodyPart(messageBodyPart);
> > > >             // Put parts in message
> >
> > > >             message1.setContent(multipart);
> > > >             // Send the message
> > > >             Transport.send(message1);
> >
> > > >         } catch (AddressException e) {
> > > >             // TODO Auto-generated catch block
> > > >             e.printStackTrace();
> > > >         } catch (MessagingException e) {
> > > >             // TODO Auto-generated catch block
> > > >             e.printStackTrace();
> > > >         }
> >
> > > >         // return null;
> >
> > > >     }
> >
> > > >     public class SMTPAuthenticator extends javax.mail.Authenticator {
> >
> > > >         public PasswordAuthentication getPasswordAuthentication() {
> > > >             String username = SMTP_AUTH_USER;
> > > >             String password = SMTP_AUTH_PWD;
> > > >             return new PasswordAuthentication(username, password);
> > > >         }
> > > >     }
> >
> > > > HTH,
> >
> > > > Thanks and Regards,
> > > > Abhiram
> >
> > > > On Mon, May 10, 2010 at 3:59 AM, Felipe Guarda <felip...@gmail.com>
> > > wrote:
> > > > > I'm trying to learn how to send emails using gwt/rpc but I have
> > > > > difficulties.
> > > > > Someone could send me a simple example that shows the
> implementation
> > > > > of the code on the client and server?
> >
> > > > > tks
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Google Web Toolkit" group.
> > > > > To post to this group, send email to
> > > google-web-tool...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com><google-web-toolkit%2Bunsubs
> cr...@googlegroups.com><google-web-toolkit%2Bunsubs
> > > cr...@googlegroups.com>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/google-web-toolkit?hl=en.
> >
> > > > --
> > > > You received this message because you are subscribed to the Google
> Groups
> > > "Google Web Toolkit" group.
> > > > To post to this group, send email to
> google-web-toolkit@googlegroups.com
> > > .
> > > > To unsubscribe from this group, send email to
> > > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com><google-web-toolkit%2Bunsubs
> cr...@googlegroups.com>
> > > .
> > > > For more options, visit this group athttp://
> > > groups.google.com/group/google-web-toolkit?hl=en.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Google Web Toolkit" group.
> > > To post to this group, send email to
> google-web-tool...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com><google-web-toolkit%2Bunsubs
> cr...@googlegroups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-web-toolkit?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> > To post to this group, send email to google-web-toolkit@googlegroups.com
> .
> > To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> .
> > For more options, visit this group athttp://
> groups.google.com/group/google-web-toolkit?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-tool...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to