How to send multiple attachments with the mail in jsp
hi.I wrote a code to send mail.but i need to send mail with multiple attachments.when i run this code iam able to send message but not files.i want to send files as attachments with the message.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 = "localhost";
Properties props = System.getProperties();
String msg_txt="";
String strStatus="";
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>
Most likely you're not specifying the path of a file on the server machine.
Similar Messages
-
Iam unable to send multiple attachments with a mail using JavaMail?
Hai to all,
Iam unable to send multiple attachments with a email,see
iam have succeeded in sending one attachment with a email.
when iam tring to add two or more attachments to a mail,
it is giving a Exception like this:
javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.IOException: No content
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:577)
at javax.mail.Transport.send0(Transport.java:151)
at javax.mail.Transport.send(Transport.java:80)
at AttachFilesModified.sendMail(AttachFilesModified.java:185)
at AttachFilesModified.main(AttachFilesModified.java:43)
this is my code snipnet:
BodyPart messageBodyPart = new MimeBodyPart();
Multipart multipart = new MimeMultipart();
if(body != null)
messageBodyPart.setText(body);
multipart.addBodyPart(messageBodyPart);
/*if(attachments != null)
for(int i = 0; i < attachments.length; i++)
String filename="D:\\nagaraju\\apachi\\axis-bin-1_3.zip";
//String s[]=filename.split("\\");
//System.out.println(s);
//String s1=s[1];
//String filename1=s[s.length-1];
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
//second file attaching
/*String filename1="C:\\nagadoc.txt";
BodyPart messageBodyPart1=new MimeBodyPart();
DataSource source1=new FileDataSource(filename1);
messageBodyPart.setDataHandler(new DataHandler(source1));
messageBodyPart.setFileName(filename1);
multipart.addBodyPart(messageBodyPart1);
mess.setContent(multipart);
Address[] allRecips = mess.getAllRecipients();
if(toStdOut)
System.out.println("done.");
//System.out.println("Sending message (\"" + mess.getSubject().substring(0,10) + "...\") to :");
System.out.println("Sending message................");
for(int i = 0; i < allRecips.length; i++)
System.out.print(allRecips[i] + ";");
System.out.println("...");
Transport.send(mess);
if(toStdOut)
System.out.println("done.");
return 0;
What's wrng with that code snipnet?
Nagaraju G.This works fine with me, try it or compare it if you want.
public void sendEmail( String from, String to,
String subject, String body) {
fMailServerConfig.put("mail.smtp.host", " <<mail server>>");
Session session = Session.getDefaultInstance( fMailServerConfig, null );
MimeMessage message = new MimeMessage( session );
try {
message.setFrom(new InternetAddress(from));
message.setRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject( subject);
message.setText( body);
//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 );
}catch (MessagingException e){
System.err.println("Cant send mail. " + e);
The error on your code might be:
BodyPart messageBodyPart1=new MimeBodyPart();
DataSource source1=new FileDataSource(filename1);
messageBodyPart.setDataHandler(new DataHandler(source1));
messageBodyPart.setFileName(filename1);
multipart.addBodyPart(messageBodyPart1);
You don't need to create a new BodyPart, and apart from that you'r seting values on "messageBodyPart" but adding "messageBodyPart1" to your multipart :P
Well see u and have a good one!
p.s. i know it's a little late from the day you posted, but at least it might help somebody else :D . -
How to send multiple Recipients using the mail.jar and activation.jar
hi!
could somebody help me. how do i send multiple Recipient using mail.jar. when i would input 2email address in to Recipient
(example: [email protected], [email protected])
i get a DEBUG: setDebug: JavaMail version 1.3.2
but if i send a single email it just works properly.
heres my code
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;
public class SendMail
public SendMail(String to, String from, String subject, String body)
//public SendMail(String to)
String message_recip = to;
String message_subject = subject;
String message_cc = "";
String message_body = body;
//The JavaMail session object
Session session;
//The JavaMail message object
Message mesg;
// Pass info to the mail server as a Properties, since JavaMail (wisely) allows room for LOTS of properties...
Properties props = new Properties( );
// LAN must define the local SMTP server as "mailhost" to be able to send mail...
//props.put("mail.smtp.host","true");
props.put("mail.smtp.host", "mailhost");
// Create the Session object
session = Session.getDefaultInstance(props, null);
session.setDebug(true);
try
// create a message
mesg = new MimeMessage(session);
// From Address - this should come from a Properties...
mesg.setFrom(new InternetAddress(from));
// TO Address
InternetAddress toAddress = new InternetAddress(message_recip);
mesg.addRecipient(Message.RecipientType.TO, toAddress);
// CC Address
InternetAddress ccAddress = new InternetAddress(message_cc);
mesg.addRecipient(Message.RecipientType.CC, ccAddress);
// The Subject
mesg.setSubject(message_subject);
// Now the message body.
mesg.setText(message_body);
// XXX I18N: use setText(msgText.getText( ), charset)
// Finally, send the message!
Transport.send(mesg);
}//end of try
catch (MessagingException ex)
while ((ex = (MessagingException)ex.getNextException( )) != null)
ex.printStackTrace( );
}//end of while
}//end of catch
}//end of SendMail
public static void main(String[] args)
//String t = "[email protected], [email protected]"; - this I think causes error
String t = "[email protected]";
String f = "[email protected]";
String s = "Hello World";
String b = "the quick brown fox jumps over the lazy dog";
SendMail sm = new SendMail(t,f,s,b);
}//end of main
}//end of class
could someone please help me im stuck-up with this. thanx!i need it ASAP
i am a beginner in java and jsp
Need to knw how can I parse the addresss field
Below
is the code
<code>
package
public class EMailBean {
private String smtp,username,password,from,bcc,subject,body,attachments,cc;
/*setter*/
public void setSmtp(String str){this.smtp=str;}
public void setUsername(String str){this.username=str;}
public void setPassword(String str){this.password=str;}
public void setFrom(String str){this.from=str;}
public void setTo(String str){this.to=str;}
public void setCc(String str){this.cc=str;}
public void setBcc(String str){this.bcc=str;}
public void setSubject(String str){this.subject=str;}
public void setBody(String str){this.body=str;}
public void setAttachments(String str){this.attachments=str;}
/*getter*/
public String getSmtp( ){return this.smtp;}
public String getUsername( ){return this.username;}
public String getPassword( ){return this.password;}
public String getFrom( ){return this.from;}
public String getTo( ){return this.to;}
public String getCc( ){return this.cc;}
public String getBcc( ){return this.bcc;}
public String getSubject( ){return this.subject;}
public String getBody( ){return this.body;}
public String getAttachments( ){return this.attachments;}
</code>
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
try {
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(mail.getFrom()));
msg.addRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
msg.addRecipient(Message.RecipientType.TO,new InternetAddress(mail.getTo()));
msg.addRecipient(Message.RecipientType.CC, new InternetAddress(mail.getCc()));
msg.addRecipient(Message.RecipientType.CC, new InternetAddress("[email protected]"));
msg.setSubject(mail.getSubject());
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Fill the message
messageBodyPart.setText(mail.getBody());
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(mail.getAttachments());
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(source.getName());
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart);
msg.setSentDate(new Date());
Transport t = session.getTransport("smtp");
try {
t.connect(mail.getUsername(), mail.getPassword());
t.sendMessage(msg, msg.getAllRecipients());
} finally {
t.close();
result = result + "<FONT SIZE='4' COLOR='blue'><B>Success!</B>"+"<FONT SIZE='4' COLOR='black'> "+"<HR><FONT color='green'><B>Mail was successfully sent to </B></FONT>: "+mail.getTo()+"<BR>";
if (!("".equals(mail.getCc())))
result = result +"<FONT color='green'><B>CCed To </B></FONT>: "+mail.getCc()+"<BR>";
if (!("".equals(mail.getBcc())))
result = result +"<FONT color='green'><B>BCCed To </B></FONT>: "+mail.getBcc() ;
result = result+"<BR><HR>";
} catch (MessagingException mex) {
result = result + "<FONT SIZE='4' COLOR='blue'> <B>Error : </B><BR><HR> "+"<FONT SIZE='3' COLOR='black'>"+mex.toString()+"<BR><HR>";
} catch (Exception e) {
result = result + "<FONT SIZE='4' COLOR='blue'> <B>Error : </B><BR><HR> "+"<FONT SIZE='3' COLOR='black'>"+e.toString()+"<BR><HR>";
e.printStackTrace();
finally {
return result;
} -
How to send multiple attachments when the number of attachment is known at
I am creating an independent E-mail component for an n tire architecture. This component gets the email message and files_to_Attach as method parameters.
Files to attach is inside an array list.
So the number of files for attachment is known only at run time.
How can I attach this files.
If I use single instance of MimeBodyPart (ib side a Four or While loop), it attaches the last file several times.
Please advise me on thishi
some related links
http://forum.java.sun.com/thread.jspa?threadID=684327&messageID=4429819
http://www.jscape.com/articles/sending_email_attachments_using_java.html
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=45&t=003546
http://www.dbforums.com/showthread.php?t=1059049
http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_21072849.html -
How to send multiple attachements in single mail
Hi All,
Currently i am using this function module SO_NEW_DOCUMENT_ATT_SEND_API1 to send mail with only one attachment.
But now i need to send multiple attachments to a single mail.
Can any one please tell me as how to send multiple attachments in single mail.
Thanks in advance.Hi
See this and do accordingly
Mailing with Attachment by ABAP Coding
Refer this link:
Mail with attachment.
FORM send_list_to_basis .
DATA: w_path LIKE rlgrap OCCURS 0 WITH HEADER LINE,
lt_index TYPE sy-tabix,
doc_type(3) TYPE c,
descr LIKE it_objpack_basis-obj_descr,
temp_data LIKE w_path,
temp1 TYPE string,
tab_lines TYPE i,
langu(15) TYPE c,
expirydate TYPE so_obj_edt,
L_FILE1(100).
CONCATENATE 'C:\' sy-repid '_' sy-datum '.XLS' INTO L_FILE1.
W_PATH-FILENAME = L_FILE1.
APPEND w_path.
CLEAR w_path.
wa_doc_chng-obj_descr = 'User List not logged on for 180 days'.
wa_doc_chng-obj_langu = 'E'.
wa_doc_chng-obj_expdat = sy-datum.
CLEAR w_subject.
CONCATENATE 'Please find attached document with list of users'
'not logged on for 180 days for client' sy-mandt
INTO w_subject SEPARATED BY space.
it_objtxt_basis-line = w_subject.
APPEND it_objtxt_basis.
CLEAR it_objtxt_basis.
it_objtxt_basis-line = text-004.
APPEND it_objtxt_basis.
CLEAR it_objtxt_basis.
CLEAR w_tab_line.
DESCRIBE TABLE it_objtxt_basis LINES w_tab_line.
READ TABLE it_objtxt_basis INDEX w_tab_line INTO l_cline.
wa_doc_chng-doc_size =
( w_tab_line - 1 ) * 255 + STRLEN( l_cline ).
CLEAR it_objpack_basis-transf_bin.
it_objpack_basis-head_start = 1.
it_objpack_basis-head_num = 0.
it_objpack_basis-body_start = 1.
it_objpack_basis-body_num = w_tab_line.
it_objpack_basis-doc_type = 'RAW'.
APPEND it_objpack_basis.
CLEAR it_objpack_basis.
LOOP AT w_path.
temp1 = w_path.
descr = w_path.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = descr
lang = 'E'
IMPORTING
rstring = descr.
CALL FUNCTION 'STRING_SPLIT'
EXPORTING
delimiter = '\'
string = descr
IMPORTING
head = descr
tail = temp_data.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = descr
lang = 'E'
IMPORTING
rstring = descr.
CALL FUNCTION 'STRING_SPLIT'
EXPORTING
delimiter = '.'
string = descr
IMPORTING
head = temp_data
tail = doc_type.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = temp1
filetype = 'BIN'
header_length = 0
read_by_line = 'X'
replacement = '#'
TABLES
data_tab = it_upload.
DESCRIBE TABLE it_upload LINES tab_lines.
DESCRIBE TABLE it_objbin_basis LINES lt_index.
lt_index = lt_index + 1.
LOOP AT it_upload.
wa_objbin_basis-line = it_upload-line.
APPEND wa_objbin_basis TO it_objbin_basis.
CLEAR wa_objbin_basis.
ENDLOOP.
it_objpack_basis-transf_bin = 'X'.
it_objpack_basis-head_start = 0.
it_objpack_basis-head_num = 0.
it_objpack_basis-body_start = lt_index.
it_objpack_basis-body_num = tab_lines.
it_objpack_basis-doc_type = doc_type.
it_objpack_basis-obj_descr = descr.
it_objpack_basis-doc_size = tab_lines * 255.
APPEND it_objpack_basis.
CLEAR it_objpack_basis.
ENDLOOP.
it_reclist_basis-receiver = '[email protected]'.
it_reclist_basis-rec_type = 'U'.
APPEND it_reclist_basis.
CLEAR it_reclist_basis.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_objpack_basis
contents_txt = it_objtxt_basis
contents_bin = it_objbin_basis
receivers = it_reclist_basis
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc EQ 0.
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
ENDIF.
ENDFORM. " send_list_to_basis
<b>Reward points for useful Answers</b>
Regards
Anji -
How to send multiple attachments thru mail?
I haven't been able to figure out how from the mail application send docs, worksheets etc as attachment. Also how to attach multiple docs in the mail. Looking for help on this.
SparasharYou need to start in the app that contains the files that you want to send as attachments and use that app's functionality to select and attach files to an email, and not start in the Mail app e.g. the GoodReader app supports multiple document types (word and excel, read only, PDFs, text files, pictures) and allows you to select one or more of them and attach/switch with them to an email.
In the Mail app itself on iOS 6 you can now press and hold the body of the email and select photos from the Photos app to attach to it. -
How to sending simple text in the mail body
Hi friends,
How to send simple text in the mail body through ABAP code
plz send me the related code and setting for that mail.
Thanks&Regards,
Srinivastry this...
FORM send_file_as_email_attachment .
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA : i_body TYPE soli_tab WITH HEADER LINE.
DATA: it_attach LIKE it_display1 OCCURS 0 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA: att_lines TYPE i.
DATA: lv_lines TYPE i.
DATA: file TYPE string.
data: g_datum like sy-datum.
data: g_datum1(10) type c.
DATA: len TYPE n.
LOOP AT it_email.
CLEAR : objpack,
objhead,
objbin,
objtxt,
reclist.
REFRESH: objpack,
objhead,
objbin,
objtxt,
reclist.
g_datum = sy-datum - 1.
concatenate g_datum6(2) '.' g_datum4(2) '.' g_datum+0(4) into
g_datum1.
doc_chng-obj_descr = 'Aged Stock more than 45 Days'.
CONCATENATE 'Aged Stock more than 45 Days' '-' it_email-vkbur INTO
doc_chng-obj_descr.
CONCATENATE 'Please find enclosed Aged Stock Details ( >45days ) report as on'
g_datum1
INTO objtxt-line SEPARATED BY space.
APPEND objtxt.
objtxt-line = ' '.
APPEND objtxt.
objtxt-line = 'Regards'.
APPEND objtxt.
objtxt-line = 'LIS SAP Projects'.
APPEND objtxt.
objtxt-line =
'PS: Pls send feedback for futher improvements to SAP office.'.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
objpack-obj_name = 'Run_prog'.
objpack-obj_descr = 'Agestock.txt'.
lv_lines = tab_lines.
APPEND objpack.
*CONCATENATE 'Plant' 'Material Number' 'Qty(More than 45days)'
*'Amount' INTO
it_display SEPARATED BY space.
append objbin.
clear: objbin.
CLEAR:it_display2.
REFRESH it_display2.
it_display2-werks = 'Plant|'.
it_display2-matnr = 'Material Number'.
it_display2-qty = '|Qty > 45 days'.
it_display2-amount = ' |Amount'.
APPEND it_display2.
it_display2-werks = ''.
it_display2-matnr = ''.
it_display2-qty = ''.
it_display2-amount = ''.
APPEND it_display2.
CLEAR : it_display2.
sort it_display1 by amount descending.
LOOP AT it_display1 WHERE werks = it_email-vkbur.
AT FIRST.
*CONCATENATE 'Plant ' 'Material Number' 'Qty(More than 45days)'
*'Amount' INTO
objbin-line SEPARATED BY space.
append objbin.
clear: objbin.
ENDAT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = it_display1-matnr
IMPORTING
output = it_display1-matnr.
it_display1-qty = TRUNC( it_display1-qty ).
MOVE-CORRESPONDING it_display1 TO it_display2.
APPEND it_display2.
CLEAR:it_display1,it_display2,objbin.
CLEAR:it_display1.
ENDLOOP.
objbin[] = it_display2[].
DESCRIBE TABLE objbin LINES tab_lines.
objhead = 'Suug'.
APPEND objhead.
objpack-transf_bin = 'X'.
objpack-head_start = 3.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
objpack-obj_name = 'Run_prog'.
objpack-obj_descr = 'Agestock.txt'.
APPEND objpack.
reclist-receiver = '[email protected]'.
reclist-rec_type = 'U'.
APPEND reclist.
=====================================================================
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = doc_chng
commit_work = 'X'
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
CLEAR : it_email.
ENDLOOP.
ENDFORM. "send_mail
Message was edited by:
Sugumar Ganesan -
How can we send multiple attachments in a mail from iPad 2
Hi,
I am using a ipad2. I want to know how we can send multiple attachments through mail from iPad. I did not find any option of doing this. Is there a way to do this.
Regards,
SatyabratYou can't do it natively on the iPad (unless you just want to send up to 5 photos from the Photos app). I use the GoodReader app which supports quite a few document/file types (e.g. PDF, Excel, Word, pictures), and from that I can select multiple files (including different types) and attach them to the same email.
-
How to handle multiple attachments in XI mail sender adapter?
Hi,
is it possible to handle multiple attachments in a mail receiving in XI?
Our customer wants to send us mails with multiple attachments and we have to convert each attachment to an idoc.
But as I know XI (receiving mails) can handle only a single attachment in a mail. Is it true?
Any ideas?
Thanks a lot!
Regards
WolfgangHi Wolfgang,
Well, although I have never tried a scenario of picking more than two attachments from one mail, I wonder if its possible in the first place!
Here are the reasons why I think it is possible:-
It is not mentioned anywhere in the SAP Notes for mail adapter that it is not possible.
*It is not mentioned anywhere in the SAP help documentation that it is not possible
*Also, I think if the receiver mail adapter can create more than one attachment, the sender should be able to pick more than one!:)
Have you tried defining a PayloadSwapBean module to pick up more than one attachment?
Just try experimenting with this particular part of the module code:-
Content-Disposition: attachment;filename="MailAttachment-1.xml"
Content-Description: MailAttachment-1
I think even the following weblog might be able to help you to a certain extent:-
"Receiving E-Mail and processing it with ABAP - Version 610 and Higher" - /people/thomas.jung3/blog/2004/09/09/receiving-e-mail-and-processing-it-with-abap--version-610-and-higher
Regards,
Sushumna
Regards,
Sushumna -
How to send multiple attachments?
Sorry if this seems like an obvious question but can it be done? Do I need an extra app or helper?
Thanks in advanceErnie,
I have had problems with sending some attachments to windows users.
i cant tell exactly what is causing it.
usually i am making .pages documents which i then export as PDFs.
many times windows users email me back that they cant even see the attached PDFs (not not open them, but cant even see them).
there seems to be some sort of bug. (yes, attach as windows friendly documents is selected).
some have suggested that attaching multiple attachments using the command click method might be at fault.
others have suggested that exporting to pdf might be a problem and the resulting pdf not always readable by windows users.
can you give any suggestion that might ensure windows users can always open my attached PDFs?
thanks -
How to attach Multiple attachments to single mail
How to attach multiple pdfs to single mail ?
or
how to attach one pdf & One excel & One word document to single mail ?
Thanks In AdvanceHello Karunya,
Please refer to the link below.
https://wiki.sdn.sap.com/wiki/display/Snippets/Send%20email%20with%20multiple%20zipped%20attachments
Regards,
P Bansal -
How to send multiple attachemnt with a Email
Hello experts,
I have problem with sending multiple attachement with a Email .
I have used program BCS_EXAMPLE_5. it is not for multiple attachment.
Please help me.
Thank you.Hello,
u can make use of these Function Modules.
SO_DOCUMENT_SEND_API1
SO_NEW_DOCUMENT_SEND_API1
'CONVERT_OTFSPOOLJOB_2_PDF'
the program which u gave using the method classes
Thank u,
santhosh
Edited by: santhosh kumar on Dec 2, 2008 2:15 PM -
How to send multiple attachment in single mail
i am using FM SO_NEW_DOCUMENT_ATT_SEND_API1 for sending mail.
pls guide me how can i modify my code so that i can send multiple attachmentsHi Manish,
Check out the links below.
E-mail multiple PDF attachments
Send a Single Mail with Multiple Attachment
Hope it helps.
Regards,
Amit
*Always reward points for helpful answers
Message was edited by:
Amit Kumar -
Need to send an attachment with the mail to the distribution list
Hi all,
How do I send an <b>attachment</b> with the e-mail to a distribution list?
I am using the FMs <b>SO_DLI_EXPAND</b> and <b>SO_OBJECT_SEND</b> to expand the distribution list and send mail to the distribution list respectively.I am getting the contents of the file in the email that is being sent. The file is being extracted from UNIX.
However, the contents of the file has to go as an attachment.
Please assist.
Thanks and regards,
AnishurHello,
You can do it like this...using SapScript:
REPORT YMAIL.
DATA: ITCPO LIKE ITCPO,
TAB_LINES LIKE SY-TABIX.
Variables for EMAIL functionality
DATA: MAILDATA LIKE SODOCCHGI1.
DATA: MAILPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: MAILHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: MAILBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILREC LIKE SOMLREC90 OCCURS 0 WITH HEADER LINE.
DATA: SOLISTI1 LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
PERFORM SEND_FORM_VIA_EMAIL.
FORM SEND_FORM_VIA_EMAIL *
FORM SEND_FORM_VIA_EMAIL.
CLEAR: MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
REFRESH: MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
Creation of the document to be sent File Name
MAILDATA-OBJ_NAME = 'TEST'.
Mail Subject
MAILDATA-OBJ_DESCR = 'Subject'.
Mail Contents
MAILTXT-LINE = 'Here is your file, would you check it?'.
APPEND MAILTXT.
Prepare Packing List
PERFORM PREPARE_PACKING_LIST.
BREAK gpulido.
Set recipient - email address here!!!
<b>*MAILREC-RECEIVER = '[email protected]'.
MAILREC-RECEIVER = '[email protected]'.
MAILREC-REC_TYPE = 'U'.</b>
APPEND MAILREC.
Set recipient - email address here!!!
*MAILREC-RECEIVER = 'BGIRALDO'.
*MAILREC-REC_TYPE = 'B'.
*APPEND MAILREC.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = MAILDATA
PUT_IN_OUTBOX = 'X'
TABLES
PACKING_LIST = MAILPACK
OBJECT_HEADER = MAILHEAD
CONTENTS_BIN = MAILBIN
CONTENTS_TXT = MAILTXT
RECEIVERS = MAILREC
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
submit rsconn01 with mode = 'INT' and return.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT MAILREC.
WRITE: / mailrec-RECEIVER(48), ':'.
IF mailrec-RETRN_CODE = 0.
WRITE 'sent successfully'.
ELSE.
WRITE 'not sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'no authorization to send to the specified number of'
WHEN 2.
WRITE: / 'document could not be sent to any of the recipients!'.
WHEN 4.
WRITE: / 'no authorization to send !'.
WHEN OTHERS.
WRITE: / 'error occurred during sending !'.
ENDCASE.
ENDFORM.
Form PREPARE_PACKING_LIST
FORM PREPARE_PACKING_LIST.
CLEAR: MAILPACK, MAILBIN, MAILHEAD.
REFRESH: MAILPACK, MAILBIN, MAILHEAD.
DESCRIBE TABLE MAILTXT LINES TAB_LINES.
READ TABLE MAILTXT INDEX TAB_LINES.
MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
Creation of the entry for the compressed document
CLEAR MAILPACK-TRANSF_BIN.
MAILPACK-HEAD_START = 1.
MAILPACK-HEAD_NUM = 0.
MAILPACK-BODY_START = 1.
MAILPACK-BODY_NUM = TAB_LINES.
MAILPACK-DOC_TYPE = 'RAW'.
APPEND MAILPACK.
Creation of the document attachment
This form gets the OTF code from the SAPscript form.
If you already have your OTF code, I believe that you may
be able to skip this form. just do the following code, looping thru
your SOLISTI1 and updating MAILBIN.
PERFORM GET_OTF_CODE.
LOOP AT SOLISTI1.
MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
APPEND MAILBIN.
ENDLOOP.
DESCRIBE TABLE MAILBIN LINES TAB_LINES.
MAILHEAD = 'TEST.OTF'.
APPEND MAILHEAD.
Creation of the entry for the compressed attachment
MAILPACK-TRANSF_BIN = 'X'.
MAILPACK-HEAD_START = 1.
MAILPACK-HEAD_NUM = 1.
MAILPACK-BODY_START = 1.
MAILPACK-BODY_NUM = TAB_LINES.
MAILPACK-DOC_TYPE = 'OTF'.
MAILPACK-OBJ_NAME = 'TEST'.
MAILPACK-OBJ_DESCR = 'Subject'.
MAILPACK-DOC_SIZE = TAB_LINES * 255.
APPEND MAILPACK.
ENDFORM.
Form GET_OTF_CODE
FORM GET_OTF_CODE.
DATA: BEGIN OF OTF OCCURS 0.
INCLUDE STRUCTURE ITCOO .
DATA: END OF OTF.
DATA: ITCPO LIKE ITCPO.
DATA: ITCPP LIKE ITCPP.
CLEAR ITCPO.
ITCPO-TDGETOTF = 'X'.
Start writing OTF code
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'YSEND_MAIL'
LANGUAGE = SY-LANGU
OPTIONS = ITCPO
DIALOG = ' '
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'START_FORM'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'MAIN'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
Close up Form and get OTF code
CALL FUNCTION 'END_FORM'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
MOVE-CORRESPONDING ITCPO TO ITCPP.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = ITCPP
TABLES
OTFDATA = OTF
EXCEPTIONS
OTHERS = 1.
Move OTF code to structure SOLI form email
CLEAR SOLISTI1. REFRESH SOLISTI1.
LOOP AT OTF.
SOLISTI1-LINE = OTF.
APPEND SOLISTI1.
ENDLOOP.
Reward points if helpful.
Thanks
Message was edited by:
Pattan Naveen -
How to send multiple attachments at runtime?
Please help
The JavaMail FAQ talks about sending attachments and the
demo programs that come with JavaMail illustrate how to do it.
Sending more than one attachment is an obvious generalization
of the examples.
What part are you confused about?
Maybe you are looking for
-
How do I save JPG from disc to iPhoto
how do I save JPG files from a disc to iphoto??
-
Update zlspr and zlsch in ABAP program
Hi to all, I need a way to update the fields zlspr and zlsch (table bseg) without using bdc and transaction FB09 because I want a possibility to roll back work. Does anybody know about a FM who supports this functionality or any other way how to sol
-
Upgrading from iPhone 2G to 3GS?
I bought my wife an iPhone 4. She already has the 3GS. When she gets her iPhone 4, can I just take the SIM card from my 2G and put it in her 3GS and use that? Do I need to reset the 3GS to factory defaults first? Will I be able to use the apps I boug
-
Qty balances are not sufficient in the Register
This messsage is getting while doing the J1IS MMBE for 1000105 shows the quantity in stock yet while executing the transaction J1is it states material Qty balances is not sufficient in the register. Let me tell you what they did 1.MIGO 2.Return Deliv
-
Is there a way to change a volume license to individual license?
I've recently upgrade all 11 of our licenses from CS5.5 to CS6, the boxed licenses worked no probs but the volume license did not. After chatting to support they informed me that the volume license will have to be upgraded by that department and the