Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1003682 // quickGMail - sends a simple text mail through GMail

JavaX fragment (include)

1  
!include once #1015973 // JavaMail
2  
3  
// user can be raw google user name or include "@gmail.com" or "@googlemail.com"
4  
5  
// auto-get password from JavaX-Secret dir
6  
static void quickGMail(S user, S to, S subject, S text) {
7  
  quickGMail(user, null, to, subject, text);
8  
}
9  
10  
// I wanted to return the message id, but how to get it?
11  
static void quickGMail(S user, S pass, S to, S subject, S text) ctex {
12  
  print("Logging in to GMail to send mail...");
13  
  user = gmailGetHandle(user);
14  
  MimeMessage message = newGMail(user, pass);
15  
  message.setFrom(new InternetAddress(user));
16  
  message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
17  
  message.setSubject(subject);
18  
  message.setText(text);
19  
20  
  Transport.send(message);
21  
  print("Sent email from " + user + "@gmail.com to " + to + ": " + quote(subject));
22  
}

Author comment

Began life as a copy of #1003304

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1003682
Snippet name: quickGMail - sends a simple text mail through GMail
Eternal ID of this version: #1003682/2
Text MD5: 8d011198debd269de3eda069973b34c0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-19 16:03:32
Source code size: 834 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 782 / 759
Version history: 1 change(s)
Referenced in: [show references]