Exception in Sender mail module
Hello
We have developed a mail module but we´re facing some problems. The module only process the first mail message. After the second "run", it throws the exception:
exception caught during processing mail message[1]; com.sap.aii.af.mp.processor.ModuleProcessorException: Error during processing local bean: localejbs/MyModule caused by: com.sap.engine.services.ejb.exceptions.BaseEJBException: Exception in method process.
The module starts working again only by restarting java stack on scmicm. Even if I stop and start the Communication Channel on Rwb, it doesnt work.
Any ideas?
Thanks!
Actually I just noticed I´m using DocumentBuilderFactory.newInstance() static class.
I checked the traces and the error is exactly on that line.
But I dont know how to deal with it.
Similar Messages
-
Getting exceptions while sending mail using javamail api
Hi to all
I am developing an application of sending a mail using JavaMail api. My program is below:
quote:
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class sms
public static void main(String args[])
try
String strstrsmtserver="smtp.bol.net.in";
String strto="[email protected]";
String strfrom="[email protected]";
String strsubject="Hello";
String bodytext="This is my first java mail program";
sms s=new sms();
s.send(strstrsmtserver,strto,strfrom,strsubject,bodytext);
catch(Exception e)
System.out.println("usage:java sms"+"strstrsmtpserver tosddress fromaddress subjecttext bodyText");
System.exit(0);
public void send(String strsmtpserver,String strto,String strfrom ,String strsubject,String bodytext)
try
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties p=new Properties(System.getProperties());
if(strsmtpserver!=null)
p.put("mail.transport.protocol","smtp");
p.put("mail.smtp.host","[email protected]");
p.put("mail.smtp.port","25");
Session session=Session.getDefaultInstance(p);
Message msg=new MimeMessage(session);
Transport trans = session.getTransport("smtp");
trans.connect("smtp.bol.net.in","[email protected]","1234563757");
msg.setFrom(new InternetAddress(strfrom));
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(strto,false));
msg.setSubject(strsubject);
msg.setText(bodytext);
msg.setHeader("X-Mailer","mtnlmail");
msg.setSentDate(new Date());
Transport.send(msg);
System.out.println("Message sent OK.");
catch(Exception ex)
System.out.println("here is error");
ex.printStackTrace();
It compiles fine but showing exceptions at run time.Please help me to remove these exceptions.I am new to this JavaMail and it is my first program of javamail.Please also tell me how to use smtp server.I am using MTNL 's internet connection having smtp.bol.net.in server.
exceptions are:
Here is exception
quote:
Javax.mail.MessagingException:Could not connect to SMTP host : smtp.bol.net.in, port :25;
Nested exception is :
Java.net.ConnectException:Connection refused: connect
At com.sun.mail.smtp.SMTPTransport.openServer<SMTPTransport.java:1227>
At com.sun.mail.smtp.SMTPTransport.protocolConnect<SMTPTransport.java:322>
At javax.mail.Service .connect(Service.java:236>
At javax.mail.Service.connect<Service.java:137>
At sms.send<sms.java:77>
At sms.main<sms.java:24>Did you find the JavaMail FAQ?
You should talk to your ISP to get the details for connecting to your server.
In this case I suspect your server wants you to make the connection on the
secure port. The FAQ has examples of how to do this for GMail and Yahoo
mail, which work similarly. By changing the host name, these same examples
will likely work for you. -
Exception in Sending Mails - Must issue a STARTTLS
Sending Mails to Multiple Users
I m getting this error, can somebody tell me what could be the possible error here:
530 5.7.0 Must issue a STARTTLS command first k39sm4421196wah
com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first k39sm4421196wah
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
at MailSender.sendMessageTo(MailSender.java:46)
at Mailer.sendMessages(Mailer.java:19)
at Mailer.main(Mailer.java:33)
Exception in thread "main" com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first k39sm44211
96wah
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
at MailSender.sendMessageTo(MailSender.java:46)
at Mailer.sendMessages(Mailer.java:19)
at Mailer.main(Mailer.java:33)Your server wants you to issue a STARTTLS command to switch the
socket to a secure connection. You can allow JavaMail to do that by
setting the "mail.smtp.starttls.enable" property to "true" when you create
the Session. See the SSLNOTES.txt file included with JavaMail and the
com.sun.mail.smtp package javadocs. -
Getting exception in sending mail
hi i got the exception as
javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first m78sm938871pye
eventhoug i tryed all the suggestion specified in the forum. But still i got this problem can any one send the sulution for me its urgent for me
Thanks In Advance
[email protected]Here i send the code but it gives starttls exception can any one help me to solve this
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;
public class SendMailUsingAuthentication
private static final String SMTP_HOST_NAME = "smtp.gmail.com";
private static final String SMTP_AUTH_USER = "vsrmca06";
private static final String SMTP_AUTH_PWD = "xxxxx";
private static final String emailMsgTxt = "Online Order Confirmation Message. Also include the Tracking Number.";
private static final String emailSubjectTxt = "Order Confirmation Subject";
private static final String emailFromAddress = "[email protected]";
// Add List of Email address to who email needs to be sent to
private static final String[] emailList = {"[email protected]"};
public static void main(String args[]) throws Exception
SendMailUsingAuthentication smtpMailSender = new SendMailUsingAuthentication();
smtpMailSender.postMail( emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);
System.out.println("Sucessfully Sent mail to All Users");
public void postMail( String recipients[ ], String subject,
String message , String from) throws MessagingException
boolean debug = true;
//Set the host smtp address
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.starttls","true");
props.put("mail.smtp.port",465);
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true");
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(debug);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++)
addressTo[i] = new InternetAddress(recipients);
msg.setRecipients(Message.RecipientType.TO, addressTo);
// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
* SimpleAuthenticator is used to do simple authentication
* when the SMTP server requires it.
private class SMTPAuthenticator extends javax.mail.Authenticator
public PasswordAuthentication getPasswordAuthentication()
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
return new PasswordAuthentication(username, password); -
Geting exception whiel sending mail from OIM
Hi,
Currently we are using Exchange 2010 and our OIM version is 9.1.0. We have written custom code for Exchange provisioning. We have migrated the admin account, through which OIM sends out mail, to Exchange 2010. We are trying to create new OIM user in IDM. We have a custom code which sends out mail to supervisor when a new contractor is created in IDM. Whiel sending mail from that admin account to supervsior we get this below error:
ERROR,08 Nov 2012 00:03:28,026,[XELLERATE.REQUESTS],Class/Method: tcEmailNotificationUtil/sendEmail encounter some problems: Sending failed;
nested exception is:
class javax.mail.MessagingException: xxx x.x.x Client was not authenticated
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: xxx x.x.x Client was not authenticated
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at com.thortech.xl.dataobj.util.tcEmailNotificationUtil.sendEmail(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
Please help us on this. Is firewall a issue as exchange server is installed on some other remote server?
Thanks.
Edited by: user11957197 on 8 Nov, 2012 1:15 AMI resolved this issue by using tcEmailNotificationUtil instead of other API
In the Adapter's Java Code, I read values from "Email Server" IT Resource and my custom Email Template definition...by using tcITResourceOperationsIntf and tcEmailDefinitionOperationsIntf)
Then by using OOTB class found in mail.jar and xlDataObjects.jar, I sent the mail..
By using OOTB class found in mail.jar and xlDataObjects.jar, I sent the mail..
import com.thortech.xl.dataobj.util.tcEmailNotificationUtil;
tcEmailNotificationUtil emailNotificationUtil = new tcEmailNotificationUtil(dataProvider);
emailNotificationUtil.constructEmail(emailTemplateName);
emailNotificationUtil.sendEmail(toEmailAddress); -
Unknown exception in sending mail
Hi,
I have written a jsp send mail application, but it is giving error that NoSuchProviderException. What to do? Plz help. I m sending the code as below:
<%@ page import="java.util.*, javax.mail.*,javax.mail.internet.*" %>
<html>
<head>
<title>E-Mail Us</title>
</head>
<body bgcolor="white" text="#003399" >
<%
if(request.getMethod().equals("POST") )
boolean status = true;
String mailServer ="SMTP_HOST";
String fnm = request.getParameter("fnm");
String lnm = request.getParameter("lnm");
String facility = request.getParameter("facility");
String subject = request.getParameter("select");
String fromEmail = "[email protected]";
String toEmail = "[email protected]";
String bccEmail = "[email protected]";
String contact =request.getParameter("select2");
String way =request.getParameter("way");
String messageEnter = request.getParameter("message");
try
Properties props = new Properties();
props.put("mail.smtp.host", mailServer);
props.put("mail.smtp.auth", "true");
Session s = Session.getInstance(props,null);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress(fromEmail);
message.setFrom(from);
InternetAddress to = new InternetAddress(toEmail);
InternetAddress bcc = new InternetAddress(bccEmail);
message.addRecipient(Message.RecipientType.TO, to);
message.addRecipient(Message.RecipientType.BCC, bcc);
message.setSubject(subject);
message.setSentDate(new Date());
message.setText(messageEnter);
message.setText(way);
message.setText(contact);
message.setText(facility);
message.setText(fnm);
message.setText(lnm);
Transport transport = s.getTransport(mailServer);
transport.connect(mailServer, "USER", "PASSWORD");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
catch(NullPointerException n)
System.out.println(n.getMessage() );
out.println(n.getMessage());
out.println("<br><br><br><br><center><b>"+" ERROR!!!"+"</b></center>");//you need to enter a message"+"</b></center>");
out.println("<br><br><center><b>"+"You need to Enter a message"+"</b></center>");
status = false;
catch (Exception e)
System.out.println(e.getMessage() );
out.println("<br><br><br><br><center><b>"+" ERROR!!!"+"</b></center>");
out.println("<br><br><center><b>"+"Your Message to " + toEmail +" and "+ bccEmail+ " failed, reason is: " + e);
status = false;
if (status == true)
out.println("<br><br><center><b>"+"Your message to " + toEmail +" and "+ bccEmail+ " was sent successfully!"+"</b></center>");
else
%>
<center>
<h1>Contact Us</h1>
<form method="post" name="mail" action="mail.jsp">
<table border="0">
<tr>
<td><b>First Name :</b></td>
<td><input type="text" name="fnm" size=24></td>
</tr>
<tr>
<td><b>Last Name :</b></td>
<td><input type="text" name="lnm" size=24></td>
</tr>
<tr>
<td><b>Facility :</b></td>
<td><input type="text" name="facility" size=24></td>
</tr>
<tr>
<td><b>Subject :</b></td>
<td> <select name="select">
<option>-------------------------------</option>
<option>Missing File</option>
<option>Correction Issue</option>
<option>Refer Us</option>
<option>Miscellaneous</option>
</select></td>
</tr>
<p>
<tr>
<td><b>Comments :</b></td>
<td><textarea name="message" rows = "10" cols="50"></textarea></td>
</tr>
<tr>
<td><b>Best way to contact :</b></td>
<td>
<select name="select2">
<option>--------------</option>
<option>Phone</option>
<option>Email</option>
<option>Fax</option>
</select>
<input type="text" name="way" size=24></td>
</tr>
</table>
<p>
<font face="Helvetica"><input type="submit"
value="Submit" name="Command">
</font>
</form></center>
<%
%>
</body>
</html>unkHi,
Have you configured the SMTP server settings in the various config files for the new version that you are using? Your log seems to suggest that it is still set to 'mail' which I think is the default.
I think the minimum you need to do is Essbase, Financial Reporting and Workspace, files as detailed below (paths may vary depending upon platform, windows & tomcat provided below even though it sounds like you've done this before).
Essbase: C:\Hyperion\AnalyticAdministrationServices\server\ OlapAdmin.properties
Financial Reporting: C:\Hyperion\BIPlus\lib\ fr_global.properties
Workspace: log in and select Navigate > Administer > Notifications
You may also need to restart the related services.
Hope this helps
Stuart Game
www.analitica.co.uk -
Exception while sending mail using javamail
below i am using the code to send a mail to [email protected]
but it is giving exception
"class com.sun.mail.smtp.SMTPSendFailedException: 554 <[email protected]>: Recipient address rejected: Relay access denied"
please can any body help me to solve this problem
Properties props = new Properties();
props.put("mail.smtp.host", "xxxxxxxxxxxxx");
Session s = Session.getInstance(props,null);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("[email protected]");
message.setFrom(from);
InternetAddress to = new InternetAddress("[email protected]");
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
Transport.send(message);I was getting the same error as the others, and I added authentication, but it still gives me the error.
All "AutomailingUtility" constants are strings
public class SMTPSender {
private Session session;
public SMTPSender() {
Properties props = new Properties();
props.setProperty("mail.smtp.host", AutomailingUtility.HOST);
props.put("mail.smtp.auth", AutomailingUtility.AUTH);
Authenticator auth = new MyAuthenticator(AutomailingUtility.USERNAME, AutomailingUtility.PASSWORD);
session = Session.getInstance(props, auth);
public void sendMessage(String toUser, String message, String subject) {
try {
Message msg = new MimeMessage(session);
msg.setSubject(subject);
msg.setSentDate(new Date());
InternetAddress ia = new InternetAddress(AutomailingUtility.FROM_ADDRESS);
msg.setFrom(ia);
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toUser));
msg.setText(message);
Transport.send(msg);
} catch (AddressException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
any ideas? -
Exception when sending mail to client on a different mail server
Hi,
When i try to send a mail to a client on a different mail server from mine I am getting the following exception.
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 not local host yahoo.com, not a gateway
It works perfectly fine when i send a mail to a client on my mail server. I am stuck up at this point - PLEASE HELP, any help greatly appreciated.
Thank you,
npailaMost of these are, of course, anti-Spam measures implemented by the various SMTP hosts, to prevent spammers from using their servers to spread the stuff (what you're doing is exactly what Spammers do as well).
In general, most properly configured SMTP servers will only accept messages if:
(a) Your IP address (as seen by that SMTP server) maps back to a proper host name, AND
(b) The recipient of the message is "local" as determined by that SMTP server, AND
(c) In many cases, the SMTP server will also cross-check your HELO/EHLO address and the MAIL FROM: value.
It may take a few attempts to get all this right. -
Hi I am getting javax.mail.sendFailedException: InvalidAddreses
nested exception is class com.sun.mail.smtp.SMTPAddressFailedException:553 sorry that domain isn't in my list of allowed rcpthosts<#5.7.1>
Here my Program:
package com.fortune2win.mail;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
// Send a simple, single part, text/plain e-mail
public class SendMail {
public void sendMail(String TO,String secCode, String UserNumber){
// SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
String from = "[email protected]";
// SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
String host = "207.234.145.236";
// Create properties, get Session
Properties props = new Properties();
props.put("mail.transport.protocol","smtp");
// If using static Transport.send(),
// need to specify which host to send it to
props.put("mail.smtp.host", host);
// To see what is going on behind the scene
props.put("mail.debug", "true");
Session session = Session.getDefaultInstance(props);
try {
// Instantiatee a message
Message msg = new MimeMessage(session);
//Set message attributes
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] address = {new InternetAddress(TO)};
msg.setRecipients(Message.RecipientType.TO,address);
msg.setSubject("F2W Player's Intimation");
// Set message content
msg.setText("Thank You for playing F2W online game.\n \n"+
"CONGRATULATIONS\n \n "+
"Your Number:" UserNumber""+"is a valid entry. \n"+
"Your Security Code:"+""+secCode+""+"\n" +
"You are entitled to claim the prize only if you produce a print of this mail."+
"\n Click www.fortune2win.com/home_index.jsp for prizedetails.\n");
//Send the message
Transport.send(msg);
catch (MessagingException mex) {
// Prints all nested (chained) exceptions as well
mex.printStackTrace();
//End of class
Plz it urgent...Help meHi thanks for the reply.
But the TO addreass I specified in the argumentlist. that is outside the program.
But the mails are going to with in the same host that is under given host address(XXX.XXX.XXX.XXX) .
Wht I mean is..mails are going with in my company...but outside mails are not going...like yahoo/gmail..etc..
plz help .
TO address i am taking from Form textbox
Regards
Varma -
Using "send mail as" with google sync
I recently migrated from an Android Phone to the Iphone 4s. I set my mail, contacts, and calenders up to sync through google sync. It is working well except the "send mail as" feature. I run 2 different email addresses through my gmail. I have my personal gmail address and my business domain address I use for work. On my android phone when I am composing an email on my phone I have the ability to choose wether I am sending the mail from my business or personal email. I have found this feature extremely useful.
I got very excited after I read that you can enable "send mail as" on google sync with ios. I went to google sync site on my safari browser and enabled the feature. I then synced the phone again. I don't know what I am missing but I do not see an option in the mail app to change the address I am sending from? Is there something else I need to enable or I am missing a simple menu that is hidden? Any help would be appreciated. Thank You@Allan Sampson -
Quote -
You're welcome.
Any problem with a 3rd party app is the responsibility of the app developer. In this case, that is Google with their Google sync program for the iPhone, so take it up with Google.
End Quote -
Very helpful. Please stop spreading your FUD* you elitest know-it-all.
This is NOT a google issue. It's an APPLE issue. APPLE'S iOS Mail App does not properly support IMAP, the very popular, very standardized protocol with which gmail (and countless other mail services) communicates with any 3rd party. (for clarity theres' also POP3 but doesn't matter here).
Let's look at a few simple observations, k?
Sender aliasing with gmail (once configured in your gmail account) works with
Thunderbird - a real IMAP client -and I think even with Outlook, arguably useless as a mail client by many yardsticks.
It works in Thunderbird on Windows.
it works in Thunderbird on a Mac.
It works in Apple Mail.app, on a Mac.
It works in the gmail app on iOS.
Are you getting the sense there's a pattern here?? I am!
It works EVERYWHERE there's a decent mail client to support it...
But it doesn't work in APPLE'S MAIL on iOS.**
Hmmmmm...
Oh, ok.. you're right. Must be a gmail thing...
oh wait, didn't work when I set up my business email server either... hmmm.
Nahh. You're right. Still must be gmail's fault...
</sarcasm>
* Fear, Uncertainty, Doubt.
** It could probably work in ANOTHER imap client on iOS but we'll never know what such a thing looks like because AAPL won't allow it (!!?) It could even work in Apple's client if they'd bring it up to circa 1998 standards.. -
I just upgraded to iOS4 on my 3GS. Everything looks good, except for sending mail. If I try to compose a new message, nothing happens. If I try to reply (clicking the curvy arrow), I get asked if I want to reply to or forward the message, but regardless of how I reply, nothing happens -- I get sent back to the original message. Does anyone have any suggestions? Thanks!
I upgraded my 3Gs to OS4 last night and now I can't get connected to my email sending or receiving. I have tried rebooting and turning the phone off. Am I missing the obvious?
-
Function module to send mail????
Hi,
which function module can we use to send mail in ABAP online program , i dont want to attach any file, just i want to notify the users by writing few lines in the email body. can u help me out in this issue..
Thanks & Regards,
Harsha RamaiahHello,
Check this sample report.
REPORT ZV_SEND_MAIL .
TABLES: EKKO.
PARAMETERS: P_EMAIL TYPE SOMLRECI1-RECEIVER
TYPES: BEGIN OF T_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
AEDAT TYPE EKPO-AEDAT,
MATNR TYPE EKPO-MATNR,
MENGE TYPE EKPO-MENGE,
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,
MENGE(16)," LIKE EKPO-MENGE,
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 MENGE
* UP TO 10 ROWS
FROM EKPO
INTO CORRESPONDING FIELDS OF 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' 'MENGE'
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
WA_CHAREKPO-MENGE
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
Cheers,
Vasanth -
Function module to send mail from SAP
Can any one please tell the Function module to send mail from SAP. The scenario is like this,I have a file in local system that i have to send to a particular mail address like [email protected] through a report program.
Hi shafiq,
1. There is some trick involved
in the binary files.
2. I have made a program (and it works fantastic)
ONLY 6 LINES FOR EMAILING
BELIEVE ME
ITS A FANTASTIC PROGRAM.
IT WILL WORK LIKE OUTLOOK EXPRESS !
3. The user is provided with
a) file name
b) email address to send mail
and it sends ANY FILE (.xls,.pdf .xyz..)
Instantaneously !
4. Make two things first :
1. Include with the name : ZAMI_INCLFOR_MAIL
2. Report with the name : ZAM_TEMP147 (any name will do)
3. Activate both and execute (2)
4. After providing filename, email adress
5. Code for Include :
10.08.2005 Amit M - Created
Include For Mail (First Req F16)
Modification Log
Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
FORM
FORM ml_customize USING objname objdesc.
Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
Header Data
Already Done Thru FM
Main Text
Already Done Thru FM
Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
Receiver List
Already done thru fm
ENDFORM. "ml_prepare
FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
object_parb =
receivers = reclist
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
IF sy-subrc <> 0.
MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
Data
DATA : pos TYPE i.
DATA : len TYPE i.
Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
CODE FOR PROGRAM
5.
REPORT zam_temp147 .
INCLUDE zami_inclfor_mail.
DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
EXTENSION = extension
NAME = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
regards,
amit m. -
Send mail using CL_BCS through function module, run in background task.
Hi,
I am running a function module in Background task. in this function module I am sending mail using CL_BCS class.
but mail is not generated. if I run the same function Module in foreground mail generated successfully....
can anyone please tell me the reason behind this.Hi i realise that The LIST_TO_ASCII thing is not working correctly in background because the the list-processing in beckground is working not the same as in dialog i think.
I can only get the last page of the list out when running in background. Any solution to this?
my code:
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
list_index = sy-lsind
TABLES
list_dyn_ascii = downtab
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
IF sy-subrc NE 0.
EXIT.
ENDIF.
Thanks ,
LH -
Which functiuon module we have to use to send mail afetr finishing the job
hi gurus
can anyone suggest me
how to send a mail after finishing the job
which function module we have to use
in reports
in scripts
in smartforms
in bdcHi Kalyan
check this simple code to understand the logic:
Convert spool to HTML and Email it.
data: list type table of abaplist with header line.
data: htmllines type table of w3html with header line.
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
start-of-selection.
* Produce a list
do 100 times.
write:/ sy-index, at 30 sy-index, at 50 sy-index.
enddo.
* Save the list
call function 'SAVE_LIST'
tables
listobject = list
exceptions
list_index_invalid = 1
others = 2.
* Convert the list
call function 'WWW_LIST_TO_HTML'
tables
html = htmllines.
* Send mail
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
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.
if sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Maybe you are looking for
-
Display non-english characters
Hi, How can i display Japanese, Chinese characters in a java application or applet? do i need some special tools? Thanks, eileen
-
Adobe Creative Cloud glitched won't allow me to download photoshop 2015
So I had to sign up for Adobe, I did. Than I downloaded the program it told me to do, I did, it was Adobe Creative Cloud. So than I went to the page to download a free trial for photoshop. I clicked on free trial and it brought me to another page, it
-
Can i reinstall audio driver ?
i m having some problems with audio and recording , i cant use stereo mix for recording ( i have posted regarding stereo mix earlier but didnt get any answer resolving the issue ) so i want to reinstall the realtek audio driver v. 6.0.1.7156 that i h
-
How to turn off the wi-fi led (f12)?
my Pavilion dv6-6c60el has F12 wi-fi led always lit. Can't switch off hitting f12, Control F12,FN F12, every combination. Note that wifi connection is disabled because i'm connected via lan. thanks, Tommaso
-
SQL Developer hangs for a few minutes after being idle for a while.
Is anyone aware of any issues with SQL Developer hanging for several minutes after being idle for several hours? After being idle for several hours (and probably minimized), when we bring up SQL Developer we just get a blank white window for several