Sending mail to multiple people
Hi,
I need to send mail to multiple people at one shot. I am using Transport.send(msg, addressTo[]); method. It is working fine. I have a requirement where in the person who receives this mail should only see his email id in the To field and not others.
if i do not set msg.setRecipient(), then the mails displays blank in To file. Where as if i set msg.setRecipient(Message.RecipientType.TO, addressTo[]), then it displays all the emails ids to which the mail is sent in the TO filed.
Please let me know if there is a way where the person will see only his email id in the To filed even when is mail to sent to multiple people.
Thanks
I also wanted to do that (sending email to a lot of people and not seeing all those address of others)
Here is what I did to solve it:
1. I have created an String array of recipients
2. I have created a method named sendEMAIL(String[] address)
3. Inside the method, there is a loop in which every iteration, the function
sendMail() is called, thus sending the same email but the address is being changed every iteration
The method I described is slow since it mails to every address thus calling the function sendMail() every iteration which will be a lot slower for a lot of email address or recipients.
With this, I have been able to send same email to different people and those people wouldn't see the email addresses of other people in the "TO" field.
jte091805
Thanks I hope this helps.
Similar Messages
-
HOW DO I SEND MAIL TO MULTIPLE PEOPLE AND THOSE PEOPLE SEE ONLY THEIR NAME?
How do I send one email to multiple addresses, but the recipients see only their name in the "To" box?
I did this and the recipient gets an email From: Me and To: Me.
If you are sending email to multiple recipients by bcc, the recipients should not be able to see the other recipients you are sending the mail to. However, they will see who the email is from which is you!
What is confusing me is how are your recipients getting your email if it's not addressed to them but to yourself?
Have you tried rebuilding Mail?
Which version of OS & Mail are you using? Asking because your system profile is showing you are using Snow Leopard yet, you posted in the ML forum. -
Problem in sending mails to multiple persons
Hi,
I have a problem in sending mails to multiple people....
My mail is using the local smtp server...The mail is to be send to multiple addresses in to and cc.
for e.g the to address will have --> [email protected];[email protected]
cc address will have --> [email protected];[email protected]
How do this i.e set multiple to and cc address...
My function that sends mail from my ejb looks like this...
// create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", host);
Session session = Session.getDefaultInstance(props, null);
try{
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
//I HAVE TO SET MULTIPLE "TO" ADDRESSES HERE INSTEAD OF JUST 1
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
//I HAVE TO SET MULTIPLE "CC" ADDRESSES HERE INSTEAD OF JUST 1
InternetAddress[] addresscc = {new InternetAddress(cc)};
msg.setRecipients(Message.RecipientType.CC, addresscc);
msg.setSubject(msgSubj);
msg.setSentDate(new java.util.Date());
msg.setText(msgText);
Transport.send(msg);
}catch (MessagingException ex) {
System.out.println("\nException handling in javaMail.java :" + ex);
Please help me out with a solution!!!Thanks in advance.
Thanks
RahulHi all,
Got the solution...
We have to use addRecipients method of the Message class to add as many receipts we want to set.
example: Message.addRecipients(type,address).
Thanks
Rahul -
Macbook Air- send mail to multiple person in contact with name of them in email
Hi there, i use macbook air, in mail, i want to know if it is possible the if i wan to send email to multiple people in my contact and the name of the person will appear in the email message like Dear......... (follow by the name of person that i saved in the contact book)
Hello Everyone,
I have another issue.My workflow when directly executed sends mail to all users very quickly.All steps gets executed very quickly.This I could see through the workflow log and SOST and SCOT.But when I try to trigger the workflow through my transaction CRMD_ORDER(i have given proper BO and event) it is taking hours and still in Inprocess status.Infact its not even going to the first step(fetch email ids).
I am totally confused on this behaviour.Kindly provide your ultimate solutions and I am very thankful for giving such good solutions to all my queries.
Regds
VLP -
How do I send mail to multiple recipients?
I am running Mavericks 10.9.5. I am having trouble sending mail to multiple recipients. I type in the first person’s name and the e-mail address appears. When I want to send mail to 2 more people, I can’t. I type a comma and then a space and then the second person’s name. All that appears is a duplication of the first person’s name. I did not have this kind of trouble when I was running OS X, version 10.6.8. I could type the names of all recipients in the “To”
line. What can I do?See the response to your other post
-
Sending mail with multiple attachment
hi.
i want to send mail with multiple attachment.
i m succeed in sending multiple attachment but the second pdf is not open.
its given error like "This file is damaged and could not be open.
pls check my code. and
give the solution....
point should be assured...........
hope all u r understand my problem..
& tell me where is i m missing something.
REPORT YSDPASALE1_MAIL LINE-SIZE 110.
data : year_month(6) type c.
data : from_date like sy-datum,to_date like sy-datum.
INITIALIZATION.
year_month = sy-datum+0(6).
CONCATENATE year_month '01' into from_date.
to_date = sy-datum.
ranges : temp for mkpf-budat.
temp-low = from_date.
temp-high = to_date.
append temp to temp.
DATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,
jobname like TBTCJOB-JOBNAME,
L_RELEASE(1) TYPE c.
CONSTANTS : l_c_device(4) VALUE 'LOCL'.
DATA : t type i value 0.
DATA : p_email1 like somlreci1-receiver,
p_sender LIKE somlreci1-receiver.
Data Declaration
DATA: gd_recsize TYPE i,gd_recsize1 TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att1 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att2 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_desc1 TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des,
gd_mtitle LIKE sodocchgi1-obj_descr.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
DATA: BEGIN OF mailstr OCCURS 0,
p_email like somlreci1-receiver,
END OF mailstr.
DATA: mailtab like STANDARD TABLE OF mailstr WITH HEADER LINE.
DATA: ypp18tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
ymis008tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
ysd15tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
ymis10tab like STANDARD TABLE OF mailstr WITH HEADER LINE.
SUBMIT YSDPASALE1 with bdt in temp
to sap-spool
with line-size = '255'
with KEEP_IN_SPOOL = 'X'
with IMMEDIATELY = ' '
WITHOUT SPOOL DYNPRO
AND RETURN
NEW-PAGE PRINT ON
DESTINATION l_c_device
IMMEDIATELY ' '
KEEP IN SPOOL 'X'
NEW LIST IDENTIFICATION 'X'
NO DIALOG.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf.
select yemail as p_email into CORRESPONDING FIELDS OF TABLE ymis008tab
from ymail
where ytcode = 'YMIS008'.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool & mail sending',
'request to be created.'.
ENDIF.
wait up to 3 seconds.
submit YSD_MONTHLY_SALES
USING SELECTION-SET 'MAIL'
to sap-spool
with KEEP_IN_SPOOL = 'X'
with IMMEDIATELY = ' ' "SPACE
WITHOUT SPOOL DYNPRO
AND RETURN
NEW-PAGE PRINT ON
DESTINATION l_c_device
IMMEDIATELY ' '
KEEP IN SPOOL 'X'
NEW LIST IDENTIFICATION 'X'
NO DIALOG.
new-page print off.
IF sy-batch EQ 'X'.
gd_attachment_desc1 = 'YMIS10'.
gd_mtitle = 'Monthly Sales Report'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf1.
loop at it_mess_att.
move it_mess_att1 to it_mess_att.
APPEND it_mess_att.
endloop.
APPEND LINES OF it_mess_att1 to it_mess_att.
free it_mess_att1.
it_mess_att[] = it_mess_att1[].
insert LINES OF it_mess_att1 into it_mess_att.
APPEND LINES OF it_mess_att2 to it_mess_att .
insert LINES OF it_mess_att1 into it_mess_att.
insert LINES OF it_mess_att2 into it_mess_att.
loop at ymis008tab into mailstr.
p_email1 = mailstr-p_email.
p_email1 = '[email protected]'.
PERFORM process_email.
endloop.
clear mailstr.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ELSE.
SKIP.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM convert_spool_to_pdf1.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att1 = gd_buffer.
APPEND it_mess_att1.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
DESCRIBE TABLE it_mess_att1 LINES gd_recsize1.
CHECK gd_recsize > 0 or gd_recsize1 > 0.
PERFORM send_email." USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email." USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = gd_attachment_desc1 .
gd_attachment_desc = 'YPP18 - Daily Highlights'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Dear Sir,'.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = 'kindly find the attached document'.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = 'Do not reply on this mail, It is generated from SAP'.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = 'Regards,'.
APPEND it_mess_bod.
it_mess_bod = 'Arpit Shah'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
it_mess_att1
using "p_email
gd_mtitle
'Testing mail generated from SAP'
'Daily Highlights Abstract Report - YPP18'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
it_attach1
using "p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1,w_doc_data1 like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data1-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
For 2nd Attachments
* Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach1 INDEX w_cnt.
w_doc_data-doc_size = w_doc_data1-doc_size +
( w_cnt - 1 ) * 255 + STRLEN( it_attach1 ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
APPEND LINES OF it_attach1 to t_attachment.
t_attachment[] = it_attach1[].
APPEND LINES OF it_attach1 to t_attachment.
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
DESCRIBE TABLE it_mess_att LINES t_packing_list-body_num.
DESCRIBE TABLE it_attach LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = 'YMIS008'."ld_attdescription.
t_packing_list-obj_name = 'YMIS008'."ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
clear t_packing_list.
for 2 attachments
data : a type i,b type i.
a = t_packing_list-body_num.
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = a + 1. "1
DESCRIBE TABLE it_mess_att1 LINES t_packing_list-body_num.
DESCRIBE TABLE it_attach1 LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = 'YMIS10'."ld_attdescription.
t_packing_list-obj_name = 'YMIS10'."ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
a = t_packing_list-body_num.
clear t_packing_list.
* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = a + 1.
t_packing_list-body_num = t_packing_list-body_num + 1.
DESCRIBE TABLE it_mess_att1 LINES t_packing_list-body_num.
t_packing_list-body_num = a + t_packing_list-body_num .
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = 'YMIS10'."ld_attdescription.
t_packing_list-obj_name = 'YMIS10'."ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
loop at ymis008tab into mailstr.
t_receivers-receiver = mailstr-p_email. "ld_email.
t_receivers-receiver = p_email1.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'. "X "Read Acknoledgement
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
endloop.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
Rgds.
ArpitHi Arpit,
Take a look at the documentation of FM 'SO_DOCUMENT_SEND_API1' for parameter PACKING_LIST. I think you should set t_packing_list-head_num to a different value than 0 for the second attachment.
Regards,
John. -
Sending Mails to Multiple Recipients using UTL_SMTP
create or replace procedure send_mail(msg_text varchar2) is
c utl_smtp.connection;
PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
BEGIN
utl_smtp.write_data(c, name || ': ' || header || utl_tcp.CRLF);
END;
BEGIN
c := utl_smtp.open_connection('outlook.abc.com');
utl_smtp.helo(c, 'abc.com');
utl_smtp.mail(c, '[email protected]');
utl_smtp.rcpt(c, '[email protected]');
utl_smtp.open_data(c);
send_header('From', '"root" <[email protected]>');
send_header('To', '"abc" <[email protected]>');
send_header('Subject', 'WARNING: Salary has been changed');
utl_smtp.write_data(c, utl_tcp.CRLF || msg_text);
utl_smtp.close_data(c);
utl_smtp.quit(c);
EXCEPTION
WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
BEGIN
utl_smtp.quit(c);
EXCEPTION
WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
NULL; -- When the SMTP server is down or unavailable, we don't have
-- a connection to the server. The quit call will raise an
-- exception that we can ignore.
END;
raise_application_error(-20000,
'Failed to send mail due to the following error: ' || sqlerrm);
END;
==============
when I execute the above using
sql> exec send_mail('hihihih');
I am getting the mails..no problems...
So..I created the following trigger and used the above procedure to send the mail...
CREATE OR REPLACE TRIGGER test_emp_table_trg
AFTER UPDATE
ON test_emp_table
FOR EACH ROW
WHEN (NEW.sal <> OLD.sal)
DECLARE
l_employee_name VARCHAR2 (240);
l_old_sal VARCHAR2 (240);
l_new_sal VARCHAR2 (240);
l_message VARCHAR2 (240);
BEGIN
/* Gets the employee full name */
BEGIN
SELECT ename
INTO l_employee_name
FROM test_emp_table
WHERE empno = :OLD.empno;
EXCEPTION
WHEN OTHERS
THEN
l_employee_name := NULL;
END;
/* Gets the old Salary */
BEGIN
SELECT sal
INTO l_old_sal
FROM test_emp_table
WHERE empno = :OLD.empno;
EXCEPTION
WHEN OTHERS
THEN
l_old_sal := 0;
END;
/* Gets the new salary */
BEGIN
SELECT sal
INTO l_new_sal
FROM test_emp_table
WHERE empno= :NEW.empno;
EXCEPTION
WHEN OTHERS
THEN
l_new_sal := 0;
END;
l_message:=
'Employee Name= '
|| l_employee_name
|| 'Old Salary= '
|| l_old_sal
|| 'New Salary= '
|| l_new_sal;
BEGIN
send_mail (l_message);
END;
END;
===================
I am not getting desired output..what might be problem friends...I am getting 0 values for old salary and new salary......
One more thing..when i use 2 receipts in the send_mail procedure like this...I added the following lines in the procedure to send to multiple receipents..
======
utl_smtp.rcpt(c, '[email protected]');
utl_smtp.rcpt(c, '[email protected]');
=============
Pleas have a look and correct me, where i went wrong....
Edited by: oraDBA2 on Sep 22, 2008 3:12 PMHi, You can use the following routine to send mail to multiple recipients through utl_smtp.
create or replace package mail_pkg
as
type array is table of varchar2(255);
procedure send( p_sender_e_mail in varchar2,
p_from in varchar2,
p_to in array default array(),
p_cc in array default array(),
p_bcc in array default array(),
p_subject in varchar2,
p_body in long );
end;
create or replace package body mail_pkg
begin
g_crlf char(2) default chr(13)||chr(10);
g_mail_conn utl_smtp.connection;
g_mailhost varchar2(255) := 'ur mail server';
function address_email( p_string in varchar2,
p_recipients in array ) return varchar2
is
l_recipients long;
begin
for i in 1 .. p_recipients.count
loop
utl_smtp.rcpt(g_mail_conn, p_recipients(i));
if ( l_recipients is null )
then
l_recipients := p_string || p_recipients(i) ;
else
l_recipients := l_recipients || ', ' || p_recipients(i);
end if;
end loop;
return l_recipients;
end;
procedure send( p_sender_e_mail in varchar2,
p_from in varchar2,
p_to in array default array(),
p_cc in array default array(),
p_bcc in array default array(),
p_subject in varchar2,
p_body in long );
end;
is
l_to_list long;
l_cc_list long;
l_bcc_list long;
l_date varchar2(255) default
to_char( SYSDATE, 'dd Mon yy hh24:mi:ss' );
procedure writeData( p_text in varchar2 )
as
begin
if ( p_text is not null )
then
utl_smtp.write_data( g_mail_conn, p_text || g_crlf );
end if;
end;
begin
g_mail_conn := utl_smtp.open_connection(g_mailhost, 25);
utl_smtp.helo(g_mail_conn, g_mailhost);
utl_smtp.mail(g_mail_conn, p_sender_e_mail);
l_to_list := address_email( 'To: ', p_to );
l_cc_list := address_email( 'Cc: ', p_cc );
l_bcc_list := address_email( 'Bcc: ', p_bcc );
utl_smtp.open_data(g_mail_conn );
writeData( 'Date: ' || l_date );
writeData( 'From: ' || nvl( p_from, p_sender_e_mail ) );
writeData( 'Subject: ' || nvl( p_subject, '(no subject)' ) );
writeData( l_to_list );
writeData( l_cc_list );
utl_smtp.write_data( g_mail_conn, '' || g_crlf );
utl_smtp.write_data(g_mail_conn, p_body );
utl_smtp.close_data(g_mail_conn );
utl_smtp.quit(g_mail_conn);
end;
end;
begin
mail_pkg.send
(p_sender_e_mail => 'urmail',
p_from => 'urmail',
p_to => mail_pkg.array( 'urmail','othersmail' ),
p_cc => mail_pkg.array( ' othermail ' ),
p_bcc => mail_pkg.array( '' ),
p_subject => 'This is a subject',
p_body => 'Hello Buddy, this is the mail you need' );
end;
/ -
Send Mail with Multiple Attachment
How to send mail with multiple attachment. The documents are in a table column BLOB. Read and attach in to mail directly.
We dont want save the documents into hard disk and attach to mail. Please Help
If you have java procedure or Pl/Sql Procedure. I think pl/sql cant. So please mail me code to [email protected] mail id. Thank you.
Thanks in advance
SelvamHi all
Thanks for your reply, already tried this methods, Its not working for my requirements. Because my attachment is can be any type like pdf,doc,txt,xls,jpg, .
And also the Utl_mail is very slow. Its using RAW type.
I can use the javamail package to solve this problem, this javamail package needs to download into server from there you can attach thus documents into mail. But I want fetch the documents and ate the same time I want attach to a mail. Like yahoo attach or msn attachment.
Thank you,
Selvam -
Sending mail with multiple dest., one is rejected - mail is rejected, why?
Hello,
I have a problem with my messaging server, while sending mails to multiple users, and one of them does not exist or is overquota.
If one of the recipients gets rejected (email address does not exists or is overquota), the email is rejected (type J register) and no one receive it.
any idea why messaging is doing this?
The queue i'm using is configured like this:
tcp_intranet notices 3 smtp nomx backoff "pt5m" "pt10m" "pt30m" subdirs 50 maxjobs 20 pool TCP_INTRANET_POOL recipient
limit 256 maytlsserver maysaslserver allowswitchchannel saslswitchchannel tcp_auth identnone noexquota
tcp_intranet-daemonand the version of messaging
imsimta version
Sun Java(tm) System Messaging Server 6.2-4.03 (built Sep 22 2005)
libimta.so 6.2-4.03 (built 04:14:30, Sep 22 2005)
SunOS smtp07 5.9 Generic_118559-28 i86pc i386 i86pc
root@smtp:/var/opt/SUNWmsgsr/config > thanks in advance
Xavierxavierm wrote:
If one of the recipients gets rejected (email address does not exists or is overquota), the email is rejected (type J register) and no one receive it.If an individual email account is overquota or an email address doesn't exist, only that RCPT TO: attempt for that individual address will be rejected -- this does not mean the email cannot be delivered to the valid recipients.
It is up to the email client to determine how an individual rejected recipient address is handled, i.e. should it continue sending the email or give up and alert the user.
any idea why messaging is doing this?This is how all efficient email servers operate. What is the email client that you are using to send the email?
The queue i'm using is configured like this:
tcp_intranet notices 3 smtp nomx backoff "pt5m" "pt10m" "pt30m" subdirs 50 maxjobs 20 pool TCP_INTRANET_POOL recipient
limit 256 maytlsserver maysaslserver allowswitchchannel saslswitchchannel tcp_auth identnone noexquota
tcp_intranet-daemon
The noexquota option does nothing on Sun Messaging Server:
"Note that these options have no effect on delivery to Messaging Server mailboxes on any platform. "
http://msg.wikidoc.info/index.php/Exquota%2C_noexquota%2C_holdexquota_Channel_Options
You may however want to try the acceptalladdresses channel option:
http://msg.wikidoc.info/index.php/Acceptalladdresses%2C_acceptvalidaddresses_Channel_Options
Regards,
Shane. -
Sending mail with multiple attachments
hi.I wrote a code to send mail.but i need to send mail with multiple attachments.here is the code i wrote.what should i do to send the mail with multiple attachments.if i run this code iam able to send mails but not attachments.please help me
<%@ page import="javax.mail.*,javax.mail.internet.*,java.util.Date,java.io.*,java.net.InetAddress,java.sql.*,java.util.Properties,java.net.*,javax.sql.*,javax.activation.*,java.util.*,java.text.*" %>
<%@ page import="java.io.*,java.sql.*,java.net.*,java.util.*,java.text.*" %>
<%
String Attachfiles1="";
String Attachfiles2="";
String Attachfiles3="";
if("Send".equalsIgnoreCase("send"))
try
String subject="",from="",url = null,to="";
String mailhost = "our local host";
Properties props = System.getProperties();
String msg_txt="";
String strStatus="";
// byte[] bin=.....;
//Adds Attechment:
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText("Here are my attachments");
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
//first attachment
DataSource source = new FileDataSource("C:\\img1.jpg");
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName("C:\\Telnor1.jpg");
multipart.addBodyPart(messageBodyPart);
//Second attachment
DataSource source2 = new FileDataSource("C:\\img2.jpg");
messageBodyPart.setDataHandler(new DataHandler(source2));
messageBodyPart.setFileName("C:\\Telnor2.jpg");
multipart.addBodyPart(messageBodyPart);
//etc...
message.setContent(multipart);
Transport.send( message );
String mailer = "MyMailerProgram";
to=request.getParameter("to");
from=request.getParameter("from");
subject=request.getParameter("subject");
msg_txt=request.getParameter("message");
props.put("mail.smtp.host", mailhost);
Session mailsession = Session.getDefaultInstance(props, null);
Message message = new MimeMessage(mailsession);
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
message.setSubject(subject);
message.setHeader("X-Mailer", mailer);
message.setSentDate(new Date());
message.setText(msg_txt);
BodyPart messageBodyPart = new MimeBodyPart();
BodyPart messageBodyPart2 = new MimeBodyPart();
Multipart multipart = new MimeMultipart(); // to add many part to your messge
messageBodyPart = new MimeBodyPart();
javax.activation.DataSource source = new javax.activation.FileDataSource("path of the file");
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName("file_name");
messageBodyPart2.setText("message"); // set the txt message
multipart.addBodyPart(messageBodyPart);
multipart.addBodyPart(messageBodyPart2);
Transport.send(message);
out.println("Message Sent");
catch (Exception e)
e.printStackTrace();
if("Attachfiles".equalsIgnoreCase("attachfiles"))
Attachfiles1=request.getParameter("fieldname1");
Attachfiles2=request.getParameter("fieldname2");
Attachfiles3=request.getParameter("fieldname3");
%>
<html>
<body>
<div class="frame">
<form action="Composemail.jsp" method="post">
<b>SelectPosition:</b> <select name="cars" >
<option value="ABAP">ABAP
<option value="saab">Saab
<option value="fiat">Fiat
<option value="audi">Audi
</select><br><br>
<table border="1" cellpadding="2" cellspacing="2">
<tr><th>Name</th>
<th>EmailId</th>
<th>ContactNumber</th>
<th>Position</th>
</tr>
<tr>
<td>
</td>
</tr>
</table><br>
<b>SelectUser :</b><select name="cars">
<option value="Administrator">Administrator
<option value="saab">Saab
<option value="fiat">Fiat
<option value="audi">Audi
</select>
<br>
<b>To :</b>           <input type="text" name="to" size="72"><br>
<b>From :</b>       <input type="text" name="from" size="72"><br>
<b>Subject :</b>   <input type="text" name="subject" size="72"><br>
<%=Attachfiles1%><br><%=Attachfiles2%><br><%=Attachfiles3%><br><br>
<b>Message:</b><br>
            <textarea rows="10" cols="50" name="message">
</textarea> <br><br>
<b>AttachedFile:</b> <input type="file" name="fieldname1" value="filename" size="50"><br><br>
<b>AttachedFile:</b> <input type="file" name="fieldname2" value="filename" size="50"><br><br>
<b>AttachedFile:</b> <input type="file" name="fieldname3" value="filename" size="50"><br><br>
            <input type="submit" name="attachfiles" value="Attachfiles">
<center>
<input type="submit" name="send" value="Send" >
</center>
</form>
</div>
</body>
</html>Create a separate MimeBodyPart object for each attachment, rather than reusing
the same one over and over. -
Sending mail with multiple attachments in jsp
hi .I wrote a code to send a mail in jsp.but now i need to send mails with multiple attachments.how can i send mail with multiple attachment.
Create a separate MimeBodyPart object for each attachment, rather than reusing
the same one over and over. -
How to send mails to multiple recipents using SO_DOCUMENT_SEND_API
Hi ,
I am using the FM "SO_DOCUMENT_SEND_API".
I am able to send an Excel sheet as attachement, but my requirement is to send multiple mails to the corresponding persons. I tried using coma, colan, semi colan as the separator in the import parameter SENDER_ADDRESS for two different mail id's but it was not useful.
I need to send mails to multiple recipens using the same FM. (keeping one person in to list and two of the persons in CC.)
can any on throw some light on this.
Thanks
rewards will be great.....................................Hi,
The code below demonstrates how to send an email to an external email address([email protected]),
where the data is stored within a .xls attachment.
Instead of the statement, <b>PARAMETERS: p_email TYPE somlreci1-receiver
DEFAULT '[email protected]'.</b>,
use select-options & give the e-mail addresses that you want.
*& Report ZEMAIL_ATTACH *
*& Example of sending external email via SAPCONNECT *
REPORT ZEMAIL_ATTACH .
TABLES: ekko.
PARAMETERS: p_email TYPE somlreci1-receiver
DEFAULT '[email protected]'.
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
wa_ekpo TYPE t_ekpo.
TYPES: BEGIN OF t_charekpo,
ebeln(10) TYPE c,
ebelp(5) TYPE c,
aedat(8) TYPE c,
matnr(18) TYPE c,
END OF t_charekpo.
DATA: wa_charekpo TYPE t_charekpo.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
*START_OF_SELECTION
START-OF-SELECTION.
Retrieve sample data from table ekpo
PERFORM data_retrieval.
Populate table with detaisl to be entered into .xls file
PERFORM build_xls_data_table.
*END-OF-SELECTION
END-OF-SELECTION.
Populate message body text
perform populate_email_message_body.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Example .xls documnet attachment'
'XLS'
'filename'
changing gd_error
gd_reciever.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp aedat matnr
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekpo.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
Build data table for .xls document
FORM build_xls_data_table.
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT it_ekpo INTO wa_charekpo.
CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
wa_charekpo-aedat wa_charekpo-matnr
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test ekpo records'.
APPEND it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY
Hope this helps.
Reward if helpful.
Regards,
Sipra -
Problem in sending mail to multiple administrators
Hi,
I have a requirement to send mail to multiple administrators.
The flow is as follows:
The user submits feedback form then the mail should be send to all the administrators with the feedback provided by user.
The code is as follows:
DECLARE
lc_body_html varchar2(4000);
P_TO VARCHAR2(50);
P_FROM VARCHAR2(50);
P_BODY_HTML VARCHAR2(250);
P_SUBJ VARCHAR2(10);
lc_usernames VARCHAR2(100);
CURSOR lcu_username IS SELECT user_name FROM emea_pmr_users WHERE is_admin='Y';
lr_username_rec lcu_username%ROWTYPE;
BEGIN
OPEN lcu_username;
LOOP
FETCH lcu_username INTO lr_username_rec;
EXIT WHEN lcu_username%NOTFOUND;
lc_usernames :=lc_usernames||lr_username_rec.user_name||',' ;
END LOOP;
CLOSE lcu_username;
lc_usernames :=RTRIM(lc_usernames,',');
lc_body_html := :P34_FEEDBACK_TEXT;
HTMLDB_MAIL.SEND(
P_TO => lc_usernames,
P_FROM => :APP_USER,
P_BODY => lc_body_html,
P_BODY_HTML => lc_body_html,
P_SUBJ => 'Test Mail');
END;
The problem here is only for the last record in table the mail is going successfully.
If I hard code p_to as '[email protected],[email protected],[email protected]'
then the mail is being send to all the 3 users successfully.
Where I am going wrong can anyone let me know?
Thanks in advance.
Sarvani.Sarvani,
1) What do you mean by "the problem here is only for the last record in table the mail is going successfully."
2) For an e-mail which doesn't work, what is the value of APEX_MAIL_QUEUE.MAIL_TO in the mail database view?
Joel -
Sending Mail to Multiple To addresses
Hi!
I want to know how to send mail to multiple mail addresses.
Thanks!Hi sowmiya,
This code would do the stuff u wanted
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class MailExample {
public static void main (String args[]) throws Exception {
String host = "";
String from = "[email protected]";
//String to = "karthik@";
String conf_email="[email protected]";
String temp_pwd="tererere";
String recipients = "[email protected],[email protected]";
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session sessionobj = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(sessionobj);
// Set the from address
message.setFrom(new InternetAddress(from));
// Set the to address for a single recipient
// message.addRecipient(Message.RecipientType.TO,new InternetAddress("[email protected]"));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(recipients, false));
// Set the subject
message.setSubject("test");
// Set the content
message.setText("test");
// Send message
Transport.send(message); -
When I try to send mail to multiple addresses, it tells me it cant send with selected server. It sends mail to one address fine.
contact your email service provider and ask them (it might treat multiple e-mails as SPAM)
Maybe you are looking for
-
How do I get the Awesome Bar to show up at the top of my Firefox Browser window?
From one day to the next when shutting down my computer to turning it on the next day, the bookmark toolbar, browser address window (& its attendant drop-down history links), Search window, Back Bar (the little arrow you click on to go back one link
-
How to make a precautionary backup of an Adobe application
I have just bought Adobe Photoshop CS6. Very expensive. I want to protect my investment by making a backup of the installation disc in case the original fails (which I think is a reasonsble thing to do). How can I do that please?
-
Macbook Pro 10.5.8 won't allow upgrade of iTunes to sync with iOS 7
Macbook Pro Mac OS X 10.5.8, won't allow upgrade of iTunes 11 to link in with iOS 7 iPhone update. Do I need to upgrade to Snow Leopard operating system? Or Mountain Leopard operating system? Help please!
-
Can't close direction windows in google map while I can in IE
I don't see the little arrows in upper right corner of the directions window in google maps, therefore, I am unable to view a map in full screen mode. I used to be able to do this. I tried the map in IE and the arrows to hide the direction windows is
-
Package SRW in Webbased Reports 6.0.5.35
Hi ! Is is possible to use the Functions in the built-in Package SRW from Reports running in the Web ? srw.run_report and srw.message seem to not do anything anymore ? Any mention of this in (the) documentation ? cheers, Jens null