Problem in sending attachment mail
hi all
i am using function module "SO_NEW_DOCUMENT_ATT_SEND_API1"
i am facing problem in sending attachment .....if width of my text line is more than 255.
pls guide me how to proceed further
Hi,
See this thread.
Re: How to email an attachment with more than 255 characters?
Hope it help you.
Regards,
Lijo Joseph
Similar Messages
-
Issue regarding sending attachment mail
hi all
i am using function module "SO_NEW_DOCUMENT_ATT_SEND_API1"
i am facing problem in sending attachment .....if width of my text line is more than 255.
pls guide me how to proceed furtherHi,
Check this threads:
SO_NEW_DOCUMENT_ATT_SEND_API1
unable to e-mail a pdf through FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
SO_NEW_DOCUMENT_ATT_SEND_API1
Best regards,
Guillaume
Message was edited by: Guillaume Garcia -
Hey. I have problems to send e-mail with Mail. The problems is I need to un active ssl ,... but when I do this,... automatically,. its active again????. Whta can i do
Try posting this in the 10.7 Mail forum. You'll get more help there.
DALE -
having problems receiving/sending e mails on ipad, deleted hotmail account and reinstated it. inbox now ok but my folders i.e drawing, deleted, sent etc have disappeared.they still show in my hotmail on my computerand iphone, they contain info i need on my ipad. How do i transfer or obtain these folders on my ipad with the info intact
when you put your mail back onto your iPad did you use the outlook option in the mail settings?
-
Hello,
I have a problem with send e-mail.
When I create a new message, the e-mail is send for customer and me, but the description of message dont send with e-mail.
I have created a Smartform that send this e-mail and your context there is information for send this information.
When I do a modification in this message, when i put a new description, a description preview is send, but a new description dont send.
Can anyboby help me.
Thanks a lot.Hi,
I already have created a development, but this found the description preview and not actual in run time.
Development:
read table gt_notif_type_text into gs_notif_type_text
with key type_text = gs_notif_text-type_text.
if sy-subrc <> 0.
clear gs_notif_type_text.
endif.
read table gt_notif_type_textt into gs_notif_type_textt
with key type_text = gs_notif_text-type_text.
if sy-subrc <> 0.
clear gs_notif_type_textt.
endif.
In the Smartform on acording abouve:
&gs_notif_type_textt-stxt()& &gs_notif_text-last_usr()& &gv_notif_textdate& &gv_notif_texttime&
Thanks. -
Problem in sending a mail in Excel Format
Hi Experts,
i have created one report which send a mail to the customer in Excel format. For that Report, i have used on function module for downloading .
the Coding is like this,
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = 'C:\YD1.XLS'
FILETYPE = 'DAT'
TABLES
DATA_TAB = ITAB_RESULT
FIELDNAMES = IOUTHEAD.
After Downloading i have send the XLS File to the Customer using user Function Module.
My Problem is,
I have attached the Excel to the Custmer.
But the Excel File not displaying the headers . But In my Business Workplace(sbwp) the Attached Excel file displaying the header and the Details . in SBWP it is displaying correctly. But when the Customer's Place(SyStem) the particular Excel File not displaying the Headers.
where and what is the error in my report?
Regards,
Neptune.MHI
GOOD
CHECK OUT THIS LINK,
http://www.thespot4sap.com/Articles/SAP_Mail_UNIX.asp
CODE
FORM SEND_MAIL.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
DATA L_NUM(3).
Creation of the document to be sent
File Name
DOC_CHNG-OBJ_NAME = 'SENDFILE'.
Mail Subject
DOC_CHNG-OBJ_DESCR = 'Delivered Mail'.
Mail Contents
OBJTXT = 'Object text'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creation of the document attachment
LOOP AT ITAB_DATA.
CONCATENATE ITAB_DATA-PRODUCTOR
ITAB_DATA-VBELN
ITAB_DATA-POSNR
ITAB_DATA-MATNR INTO OBJBIN.
APPEND OBJBIN.
ENDLOOP.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = 'ORDERS'.
APPEND OBJHEAD.
Creation of the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'TXT'.
OBJPACK-OBJ_NAME = 'WEBSITE'.
OBJPACK-OBJ_DESCR = 'ORDERS.TXT'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
Completing the recipient list
target recipent
clear RECLIST.
RECLIST-RECEIVER = '[email protected]'.
RECLIST-EXPRESS = 'X'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
copy recipents
clear RECLIST.
RECLIST-RECEIVER = '[email protected]'.
RECLIST-EXPRESS = 'X'.
RECLIST-REC_TYPE = 'U'.
RECLIST-COPY = 'X'.
APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
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.
ENDFORM. " SEND_MAIL
THANKS
MRUTYUN -
Problems with sending attachements.
Hello I've a problem with sending attachments.
I've got mail Version 5.0 (1244.2/1244.3) and Hosted Exchange (xs4all in the Netherlands). Most of my mail works fine (sending and receive mails).
The most irritating problem is I cannot send messages with a attachement even 1 KB.
Hope anyone can help?
Ohter synchronisation Calender & contacts are even not working fine - but a cable will help. So if anyone can help there to, I will be happy.
Thanks VanessaIm having same problem with BTINTERNET account email, tbh ive had issues with this from the start. keeps going on about yahoo *** is that about... could do with someone verifying settings ive done what all the website says but same issue....attachment is only 11.7mb surely thats not an issue.......anybody know whats going on????
-
$emailFrom = "[email protected]"
$emailTo = "[email protected]"
$subject = "$env:COMPUTERNAME : A VM was successfully migrated."
$body = "$env:COMPUTERNAME : A VM was successfully migrated."
$smtpServer = "smtp.domain.com"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)
this is a template of a ps1 script i wrote. This will send the above email based on a specific event ID for the microsoft failover cluster / operational, say ID 5143 for example. My question is how do i include in that script to also include a copy of the
log for that event ID in the body of the email ?You problem with this code is that the SMTPClient send method does not handle attachements.
Instead, try creating the message, using the system.net.mail.mailmessage class to create the message.Then create a mail attachment. Finally, add the attachment to the message. This allows you to craate an attachment, then use the SMTPServer object to send
that mail.
The code should look something like this:
$To = "[email protected]"
$From = "[email protected]"
$Subject = "Using the .NET SMTP client."
$Body = "Using this .NET feature, you can send an e-mail message from an application very easily."
# Create mail message
$Message = New-Object System.Net.Mail.MailMessage $From, $To, $Subject, $Body
$AttchmentText = get-content C:\foo\aaaaaaa.txt # or whatever
# Now create Attachement content type
$ct = new-object System.Net.Mime.Contenttype
$ct.name = 'text/plain'
# Now create an attachment of that type
$attachment = [System.Net.Mail.Attachment]::CreateAttachmentFromString($attchmenttext,$ct)
# Next add Attachment to the message
$message.Attachments.Add($attachment)
# and now create smtp server
$smtpServer = "COOKHAM8"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)
I tested this script on my system and it works. You may need to play around a bit with the attachment, in terms of content type, etc.
Thomas Lee <[email protected]> -
Problem in Sending External Mail
Hi all,
I am facing a problem in sending message to the external mail server. My problem is i have created a workflow template and in that i have created a send mail step and in that i am giving a message and the recipient type is email address and the email address is [email protected]
But i am not receiving any mail to my outlook. The configuration in scot are perfect.
When i tried to send a message from my inbox new message i can able to see the mail in my outlook.
Please help me in this issue, it is very urgent.
Regards
Balaji E.Hi Prasath,
Thanks for your kind help. I checked that too, but giving me an error
Short Text
"Cannot process message in SAP System"
Long Text:
Cannot process message in SAP System
Message no. XS817
Diagnosis
Processing could not be continued due to a technical or configuration
error in the SAP system.
System Response
Processing was terminated.
Procedure
Processing was terminated in the SAP system. The reason is given in the
details below:
The received e-Mail address WIPRO6 does not corres
Can any one help me in this issue.
Note : For the user WF-Batch there is no email id specified then i specified that and saved it.
Regards,
Balaji E. -
Problem to send a mail of notify to SAP Inbox instead Outlook Inbox
Hi all,
I have a customer that it's already done an upgrade to SAP_HR 4.7 and SAP_BASIS 6.20.
I haven't modify the old Workflow and I use the standard task to send the mail of notify in order to leave request.
I'm using the method SENDTASKDESCRIPTION of object SELFITEM with type address U and the mail address (external).
But the mails aren't sending to Outlook, they are sending to SAP Inbox.
So the employee see the mail into the ESS portal instead to see the mail in Outlook.
Could you suggest me if the problem is in the task of workflow, or in SCOT or in mail server, please?
Are there a new functionality in SAP in order to search the user linked with the mail address?
Thanks in advance for any suggestion.
Best Regards
Luca MoschioniHi Luca, i have the same problem, did you found any solution to this?
thanks you. -
Problem while sending the mail from sap
Hi experts,
I am facing some problem while sending mail from sap to external mail.
this is th code i am using but it is not working. plz check and tell me.
REPORT ZMAIL_DEMO.
data: maildata type sodocchgi1.
data: mailtxt type table of solisti1 with header line.
data: mailrec type table of somlrec90 with header line.
start-of-selection.
break-point.
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test'.
maildata-obj_langu = sy-langu.
mailtxt-line = 'This is a test'.
append mailtxt.
mailrec-receiver = 'SOME MAIL ID'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'RAW'
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. "( did not receive any mail) *
write : 'mail sent'.
endif.Hi,
Please check with the following code.
TABLES: KNA1.
data for send function
DATA DOC_DATA LIKE SODOCCHGI1.
DATA OBJECT_ID LIKE SOODK.
DATA OBJCONT LIKE SOLI OCCURS 10 WITH HEADER LINE.
DATA RECEIVER LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE.
SELECT * FROM KNA1 WHERE ANRED LIKE 'C%'.
WRITE:/ KNA1-KUNNR, KNA1-ANRED.
send data internal table
CONCATENATE KNA1-KUNNR KNA1-ANRED
INTO OBJCONT-LINE SEPARATED BY SPACE.
APPEND OBJCONT.
ENDSELECT.
insert receiver (sap name)
REFRESH RECEIVER.
CLEAR RECEIVER.
MOVE: 'any_email'_ TO RECEIVER-RECEIVER, " SY-UNAME
'X' TO RECEIVER-EXPRESS,
'U' TO RECEIVER-REC_TYPE.
APPEND RECEIVER.
insert mail description
WRITE 'Sending a mail through abap'
TO DOC_DATA-OBJ_DESCR.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_DATA
IMPORTING
NEW_OBJECT_ID = OBJECT_ID
TABLES
OBJECT_CONTENT = OBJCONT
RECEIVERS = RECEIVER
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. -
Problems with sending e-mails on I-Mac.
I have a problem sending e-mails on my I-Mac and have been told to delete my e-mail account and start again. However I have also been told that if I do this I could loose all e-mails associated to my account. Could you advise on this please.
OS X Mail: Troubleshooting sending and receiving email messages
-
Three days ago our Intel iMac and two other Intel Mac Pros have developed a problem when sending an email in Mail. All of the Mail settings have been checked by our ISP and are correct. The computers are running Leopard OS. When sending the email you hit the send button and the mail activity indicator goes across as normal. When the blue line is right across it just hangs and does not clear and eventually a drop down window asks you to "try with selected server".
This problem started after a security update.
We are also having problems when trying to log onto any secure password protected website. None of the computers will log on.
It might also be useful to know is that we also have a MacBookPro which is running Snow Leopard (and is also on the same network as the other computers) and Mail and logging onto secure websites are (thankfully) working fine.
We have spoken to our computer supplier and their support team have tried various option like seeing if "keychains" etc are okay but they are at a loss as to what the problem is.
We have also got our ISP looking into it too but they have not come back as yet.
Has anyone got any ideas?Each of these two particular accounts should have its own outgoing mail server selected in the Mail > Preferences > Accounts > Account Information > Outgoing Mail Server (SMTP): popup list. This is to ensure that messages sent from each of these accounts use that account's outgoing server, necessary because these providers do not allow other accounts/user names to use their servers to send messages.
-
Problems when sending e-mails to a large number of...
Hello, I've noticed that I have a problem sending e-mails to multiple users, such as when I choose a group to send to instead of single users.
Also, when I reply to all, I can see all the recipients and the subject (everything is still intact when I check my sent messages after it's sent as well), but when I log onto my Gmail and check, the sent e-mail has no subject and is only sent to a few of the recipients.
Anyone have any idea what's wrong?Bump
-
Problem while sending a mail with smtp and ssl
Hi all,
I am new to java mail . I have downloaded one java program to send the mail. I have configured smt and port address.And my System firewall is also in off mode
Still i am unable to send the mail
The following code is my program import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.URLName;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import com.sun.mail.smtp.SMTPSSLTransport;
To use this program, change values for the following three constants,
SMTP_HOST_NAME -- Has your SMTP Host Name
SMTP_AUTH_USER -- Has your SMTP Authentication UserName
SMTP_AUTH_PWD -- Has your SMTP Authentication Password
Next change values for fields
emailMsgTxt -- Message Text for the Email
emailSubjectTxt -- Subject for email
emailFromAddress -- Email Address whose name will appears as "from" address
Next change value for "emailList".
This String array has List of all Email Addresses to Email Email needs to be sent to.
Next to run the program, execute it as follows,
SendMailUsingAuthentication authProg = new SendMailUsingAuthentication();
public class SendMailUsingAuthentication
//private static final String SMTP_HOST_NAME = "smtp.mail.yahoo.com";
private static final String SMTP_HOST_NAME = "smtp.gmail.com";
private static final String SMTP_AUTH_USER = "admijn.ramd";
private static final String SMTP_AUTH_PWD = "hairamu";
private static final int SMTP_PORT = 465;
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]", "[email protected]"};
public static void main(String args[]) throws Exception
SendMailUsingAuthentication smtpMailSender = new SendMailUsingAuthentication();
smtpMailSender.postMail( emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);
public void postMail( String recipients[ ], String subject,
String message , String from)
try{
boolean debug = false;
//Set the host smtp address
// Set the host smtp address
Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.port", SMTP_PORT);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.socketFactory.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
SecurityManager security = System.getSecurityManager();
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.setText(message);
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}catch (MessagingException e) {
// TODO: handle exception
e.printStackTrace();
* SimpleAuthenticator is used to do simple authentication
* when the SMTP server requires it.
private class SMTPAuthenticator extends javax.mail.Authenticator
public PasswordAuthentication getPasswordAuthentication()
try{
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
System.out.println("username "+ username+" Password"+password);
return new PasswordAuthentication(username, password);
}catch (Exception e) {
return null;
And i am getting the following exceptions
javax.mail.MessagingException: Exception reading response;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1611)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1369)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
at javax.mail.Service.connect(Service.java:310)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at javax.mail.Transport.send0(Transport.java:188)
at javax.mail.Transport.send(Transport.java:118)
at com.FutureSoft.org.SendingMail.SendMailUsingAuthentication.postMail(SendMailUsingAuthentication.java:123)
at com.FutureSoft.org.SendingMail.SendMailUsingAuthentication.main(SendMailUsingAuthentication.java:70)
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:88)
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1589)
... 9 morehi neuro11
the following code is for sending mail its is working fine in my system, just change the
SMTP_AUTH_USER = "tina.numi"; with u r email user name
SMTP_AUTH_PWD = "abdcde"; u r gmail password
emailFromAddress = "[email protected]"; ur gmail addres
emailList = {"[email protected]"}; receipient list .
and u must sure that u r internet is on and firewall should be off . some times firewall restricts you to communicate with gmail port number
Please make u r firewall off and source code is
package com.FutureSoft.org.SendingMail;
Some SMTP servers require a username and password authentication before you
can use their Server for Sending mail. This is most common with couple
of ISP's who provide SMTP Address to Send Mail.
This Program gives any example on how to do SMTP Authentication
(User and Password verification)
This is a free source code and is provided as it is without any warranties and
it can be used in any your code for free.
Author : Sudhir Ancha
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.URLName;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import com.sun.mail.smtp.SMTPSSLTransport;
To use this program, change values for the following three constants,
SMTP_HOST_NAME -- Has your SMTP Host Name
SMTP_AUTH_USER -- Has your SMTP Authentication UserName
SMTP_AUTH_PWD -- Has your SMTP Authentication Password
Next change values for fields
emailMsgTxt -- Message Text for the Email
emailSubjectTxt -- Subject for email
emailFromAddress -- Email Address whose name will appears as "from" address
Next change value for "emailList".
This String array has List of all Email Addresses to Email Email needs to be sent to.
Next to run the program, execute it as follows,
SendMailUsingAuthentication authProg = new SendMailUsingAuthentication();
public class SendMailUsingAuthentication
//private static final String SMTP_HOST_NAME = "smtp.mail.yahoo.com";
private static final String SMTP_HOST_NAME = "smtp.gmail.com";
private static final String SMTP_AUTH_USER = "tina.numi";// gmail username
private static final String SMTP_AUTH_PWD = "abdcde";// gmail password
private static final int SMTP_PORT = 465;
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]";// gmail id
// 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);
public void postMail( String recipients[ ], String subject,
String message , String from)
try{
boolean debug = false;
//Set the host smtp address
// Set the host smtp address
Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.port", SMTP_PORT);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.socketFactory.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
SecurityManager security = System.getSecurityManager();
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getInstance(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.setText(message);
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport t = session.getTransport("smtps");
try {
t.connect(SMTP_HOST_NAME, SMTP_AUTH_USER, SMTP_AUTH_PWD);
t.sendMessage(msg, msg.getAllRecipients());
catch(Exception e){}
finally
t.close();
}catch (MessagingException e) {
// TODO: handle exception
e.printStackTrace();
* SimpleAuthenticator is used to do simple authentication
* when the SMTP server requires it.
private class SMTPAuthenticator extends javax.mail.Authenticator
public PasswordAuthentication getPasswordAuthentication()
try{
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
System.out.println("username "+ username+" Password"+password);
return new PasswordAuthentication(username, password);
}catch (Exception e) {
return null;
try this . all the best
Maybe you are looking for
-
Missing stuff/altered settings after clearing cache
So I wanted to clear up disk space by clearing up the cache. I had not done this before so I did it for the first time. I cleared up the caches from both the main Macintosh HD device and my user name. I went to the Library folder, then to the cache f
-
Basic ?: application name and URL
I have a basic question. The web.xml file has one name for an application. If a war file is named something else, that seems to affect the URL you have to use. WHat is the relation between 1) the app name given in the web.xml file and 2) the file nam
-
Song name won't display in grid view
I have long had a problem whereby the song-name column was missing when viewing a single album from the grid view. There is an archived, unanswered question on the very same question here: http://discussions.info.apple.com/thread.jspa?threadID=181812
-
Received a manual from a supplier in PDF format. Left and right 1/2 inch of document does not print. Tried letter & legal paper, Adobe help and zooming.
-
Hi there I just have written down the following program.Program runs successfully and I get the results.But the only issue is that I want to print out the common number from this program.E.G If I enter 1,2,3,4,5,5,5,6,7,8,it should display the common