Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sending mail with attachments through smtp

Featured Replies

Good afternoon,
I implemented the  module present in the demo file of Scriptmaster entitled "Send Email With Attachments".
I do not meet problem - excepted a relative slowness via my ISP -smtp.free.fr and the mails are forwarded with their attachment.
Yesterday finding me at a friend's home, I changed the smtp in question for that of his ISP (smtp.orange.fr ): and then nothing is transmitted (message and attachment) !

Some forums tell to fix the port to 587 but how in the smtphost field ?

 

Thanks

Noël

add 

props.setProperty('mail.smtp.port', 587)

??

  • Author

John

I tried as you said (I think) by adding as follows, once with simple quotes, once with double quotes...

 

import javax.mail.*;
import javax.mail.internet.*;

Properties props = new Properties();
props.setProperty("mail.smtp.host", smtpHost);
props.setProperty("mail.smtp.port", 587);

MimeMessage msg = new MimeMessage(Session.getInstance(props));
Multipart content = new MimeMultipart();

I have always an error and the text returned is

 

groovy.lang.MissingMethodException: No signature of method: java.util.Properties.setProperty() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [mail.smtp.port, 587]
Possible solutions: setProperty(java.lang.String, java.lang.String), getProperty(java.lang.String), getProperty(java.lang.String, java.lang.String), hasProperty(java.lang.String), getProperties()

Parameters:
{[email protected], [email protected], subject=Envoi avec Cerfa, body=I'm testing the "sending email with attachments" utility in ScriptMaster.  Works great! Special characters test: éüîñ, smtpHost=smtp.orange.fr, attachmentPath=/Users/ND/Desktop/codes site PEP83.pdf}

---Script---
Script:
import javax.mail.*;
import javax.mail.internet.*;

Properties props = new Properties();
props.setProperty("mail.smtp.host", smtpHost);
props.setProperty("mail.smtp.port", 587);

MimeMessage msg = new MimeMessage(Session.getInstance(props));
Multipart content = new MimeMultipart();
// first the message body
MimeBodyPart bodyPart = new MimeBodyPart();
bodyPart.setText(body, "UTF-8");
content.addBodyPart(bodyPart);
// then the attachment
MimeBodyPart attachmentPart = new MimeBodyPart();
attachmentPart.attachFile(attachmentPath);
content.addBodyPart(attachmentPart);
msg.setContent(content);
msg.setSubject(subject);
msg.setFrom(new InternetAddress(from));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
Transport.send(msg);
return true

And this is not very speaking for me (two years ago java was only an exotic dance for me )

Thanks for help

Noël

  • Author

Hello !

Finallly I just found my error in the adptation of the script contained in the demo file. I used finally the script with authentification and added the line props.setProperty('mail.smtp.port', 587) replacing 587 by a fm_port_smtp value. If someone needs file contact me.

Thanks and have a good week-end

Noël

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.