Hi, I'm trying to use ivy API to send mail in my Designer (v7.1.0.58009). I send an email with code snippet like this:
But I got an exception with content: Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1; nested exception is: java.net.ConnectException: Connection refused: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2118) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:712) at javax.mail.Service.connect(Service.java:366) at javax.mail.Service.connect(Service.java:246) at javax.mail.Service.connect(Service.java:195) at javax.mail.Transport.send0(Transport.java:254) at javax.mail.Transport.send(Transport.java:124) at ch.ivyteam.ivy.email.internal.SendMail.doSendMessage(SendMail.java:136) at ch.ivyteam.util.callable.AbstractExecutionContext.lambda$0(AbstractExecutionContext.java:28) at ch.ivyteam.util.callable.AbstractExecutionContext.callInContext(AbstractExecutionContext.java:16) at ch.ivyteam.util.callable.AbstractExecutionContext.executeInContext(AbstractExecutionContext.java:26) at ch.ivyteam.ivy.email.internal.SendMail.sendMessage(SendMail.java:115) at ch.ivyteam.ivy.email.SimpleMailSender.sendMessage(SimpleMailSender.java:94) at ch.ivy.gawfs.mail.Mail.lambda$0(Mail.java:29) at ch.ivyteam.util.callable.AbstractExecutionContext.callInContext(AbstractExecutionContext.java:16) at ch.ivyteam.ivy.security.internal.SecurityManager.executeAsSystem(SecurityManager.java:1128) at ch.ivy.addon.portalkit.util.IvyExecutor.executeAsSystem(IvyExecutor.java:14) ... 123 more I think the problem is that API SimpleMailSender.sendMessage() uses port 25 which is cannot be accessed to connect to SMTP server: Couldn't connect to host, port: localhost, 25; timeout -1. I also tested email sending function with UI and could send email successfully: You see, it's using port 2525. If I change port to 25, I cannot send email. So how can I config the port when sending the email with ivy API? Thank you asked 10.05.2018 at 00:29 nguyen_to |
I made a sample on GitHub: https://github.com/ivy-samples/mail-over-java-api-sample In this sample I show you how you could wrap the Mail Activity in a Sub Process with an own Java API. Because for now the most proper way to send mail in ivy is still over the mail step. You won't have any curious problems. In future - ivy should provide an java api to send mail (e.g. answered 10.05.2018 at 14:49 Alex Suter ♦♦ Hi @Alex Suter, can I send multi attachments using E-Mail step of ivy. I see that in tab Attachments of E-Mail step, I can only put one attachment file by one attachment row. Assume that I have a dynamic attachment files: Map< String, File > in.attachedFiles, how can I attach that map to email.
(11.05.2018 at 03:56)
nguyen_to
That's the bad part. Here is a solution for that: https://answers.axonivy.com/questions/1130/how-to-send-a-variable-number-of-attachments-in-e-mail-step
(11.05.2018 at 04:08)
Alex Suter ♦♦
@Alex Suter, as I understand from the link you provided, the solution can be applied if we already known the number of attachments. But my situation has a difference, that is the number of attachments is dynamic, they are a list of files from a java variable!
(11.05.2018 at 10:09)
nguyen_to
Yes. You could fill up your generic mail step with 100 of these entries. I assume nobody sends email with 100 entries.
(11.05.2018 at 10:23)
Alex Suter ♦♦
Hello @Alex Suter, one more question, I got error in log when trying to attach file: IllegalArgumentException: File could not be found! C:\work\designer7.1.0.58009_Windows_x64\files\application\testFile.txt. But I'm sure this file with this path exists! Do you know what is the problem here. Thank you!
(14.05.2018 at 06:49)
nguyen_to
I got the reason, because I used wrong File api (java.io.File)
(14.05.2018 at 07:30)
nguyen_to
showing 5 of 6
show 1 more comments
|
Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Tags:
Asked: 10.05.2018 at 00:29
Seen: 3,356 times
Last updated: 14.05.2018 at 07:32