Sending a message to fax using JavaMail

Hello all,
we are trying to create a system to send messages. The input will come from an Oracle 9i (9.0.2) database, our goal is to create email messages which can either be delivered to an email address or to a fax number.
The systems works if all addresses are regular email adresses, but we get the following message when using a fax number :javax.mail.internet.AddressException: Illegal route-addr in string ``fax:[email protected]''
I have already change the parse-method to parseHeader with the parseOption false, so that the addresses are not controlled against the standard. I expect the ':' (colon) in fax:012345678 is the cause of our problem, replacing it with a random character returns a 'normal' error message for a non-existing address.
I have included the log message with the exception, the sourcecode of our SendMailTest and the source of SendMail.
Is there any work around to this colon, so we can send faxes as well as emails.
Kind regards,
Nemata
log message----------------------------------------------------
C:\ProgramFiles\jdevstudio1013\jdk\bin\javaw.exe -ojvm -classpath C:\ProgramFiles\jdevstudio1013\jdev\mywork\ocbs\Client\classes;C:\ProgramFiles\jdevstudio1013\j2ee\home\lib;C:\ProgramFiles\jdevstudio1013\j2ee\home\lib\mail.jar;C:\ProgramFiles\jdevstudio1013\j2ee\home\lib\activation.jar com.vdscomputing.carpinvest.ocbs.db.io.SendMailTest
Constructor entered
return from constructor
com.vdscomputing.carpinvest.ocbs.db.io.SendMail@a Hello
javax.mail.internet.AddressException: Illegal route-addr in string ``fax:[email protected]''
message sent
Process exited with exit code 0.
source SendMailTest-------------------------------------
package com.vdscomputing.carpinvest.ocbs.db.io;
//class designed to test SendMail
public class SendMailTest {
public static void main( String args[]) {
String SMTPserver = "192.168.1.23";
String SMTPport = "25";
String Sender = "[email protected]";
String Recipient ="fax:[email protected]";
String CcRecipient = "[email protected]";
String BccRecipient = "";
String Subject = "faxinationTest";
String Body = "test mail 12 from test class";
String[] ErrorMessage = new String[1];
String Attachments ="";
// create mesage and monitor constructor
SendMail testMessage = new SendMail();
System.out.println("return from constructor");
System.out.println(testMessage + " Hello");
testMessage.Send(SMTPserver, SMTPport, Sender, Recipient, CcRecipient,
BccRecipient, Subject, Body, ErrorMessage, Attachments);
System.out.println("message sent");
Source SendMail---------------------------------------
package com.vdscomputing.carpinvest.ocbs.db.io;
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SendMail {
//default constructor with monitor message
public SendMail(){
System.out.println("Constructor entered");
// preparing the message and sending it
public static int Send(String SMTPServer,
String SMTPPort,
String Sender,
String Recipient,
String CcRecipient,
String BccRecipient,
String Subject,
String Body,
String ErrorMessage[],
String Attachments) {
// Error status;
int ErrorStatus = 0;
     // create some properties and get the default Session;
     Properties props = System.getProperties();
     props.put("mail.smtp.host", SMTPServer);
     props.put("mail.smtp.port", SMTPPort);
Session session = Session.getDefaultInstance(props, null);
try {
     boolean ParseOption = false; //do not enforce RFC822
// create a message;
MimeMessage msg = new MimeMessage(session);
// extracts the senders and adds them to the message;
InternetAddress[] TheAddresses =
InternetAddress.parseHeader(Sender, ParseOption);
msg.addFrom(TheAddresses);
     // extract the recipients and assign them to the message;
InternetAddress[] TheAddresses =
InternetAddress.parseHeader(Recipient, ParseOption);
msg.addRecipients(Message.RecipientType.TO,
TheAddresses);
     // extract the Cc-recipients and assign them to the message;
if (null != CcRecipient) {
InternetAddress[] TheAddresses =
InternetAddress.parseHeader(CcRecipient, ParseOption);
msg.addRecipients(Message.RecipientType.CC,
TheAddresses);
     // extract the Bcc-recipients and assign them to the message;
if (null != BccRecipient) {
InternetAddress[] TheAddresses =
InternetAddress.parseHeader(BccRecipient, ParseOption);
msg.addRecipients(Message.RecipientType.BCC,
TheAddresses);
// subject field;
msg.setSubject(Subject);
// create the Multipart to be added the parts to;
Multipart mp = new MimeMultipart();
// create and fill the first message part;
MimeBodyPart mbp = new MimeBodyPart();
mbp.setText(Body);
// attach the part to the multipart;
mp.addBodyPart(mbp);
// attach the files to the message;
if (null != Attachments) {
int StartIndex = 0, PosIndex = 0;
while (-1 != (PosIndex = Attachments.indexOf("///",
StartIndex))) {
// create and fill other message parts;
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds =
new FileDataSource(Attachments.substring(StartIndex,
PosIndex));
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
PosIndex += 3;
StartIndex = PosIndex;
// last, or only, attachment file;
if (StartIndex < Attachments.length()) {
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds =
new FileDataSource(Attachments.substring(StartIndex));
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
// add the Multipart to the message;
msg.setContent(mp);
// set the Date: header;
msg.setSentDate(new Date());
// send the message with monitor message
Transport.send(msg);
System.out.println("message on transport");
} catch (MessagingException MsgException) {
ErrorMessage[0] = MsgException.toString();
System.out.println(ErrorMessage[0]); // catch to console
Exception TheException = null;
if ((TheException = MsgException.getNextException()) !=
null)
ErrorMessage[0] = ErrorMessage[0] + "\n" +
TheException.toString();
ErrorStatus = 1;
return ErrorStatus;
}

Hi,
I want to fax using java. presently I m using mail api to email & its working. Now I have to fax the attached pdf file with out using any third party or commercial software.
Any idea or suggestion would be very help full
regards
Prakash Sen

Similar Messages

  • Could you some one help me how to send a message on twitter using Oracle SOA?

    Hi Team,
              I am trying to send a message from Oracle SOA to Twitter, But i am not able to do the scenario.Could you some one help me how to send a message on twitter using Oracle SOA?
    Regards,
    Kiran

    Very challenging and doubtful at the same time !
    I don't think, its going to be a straight-forward one... Read about OAuth twitter authentication, before you try to post tweets.

  • I can't send an SMS on my iPhone 6 , I get the message "iMessage must be enabled to send this message" I dont use iMessage, I just want to send an as SMS

    I can't send an SMS on my iPhone 6 , I get the message "iMessage must be enabled to send this message" I dont use iMessage, I just want to send an as SMS

    SMS is a cellular carrier function.  Contact your cellular carrier and make sure you are correctly set up with an SMS plan.

  • Sending fax using javaMail

    Hi,
    Iam working on an assignment where I should be able to send a page via email or efax. Iam using JavaMail for email. Not sure what to do for the Fax.
    Someone help me.
    Thanks
    Jo

    I think you have to write thr protocol yourself for eFax just search for it and you will hopefully find som info how the protocol is built!
    .leonard

  • Problem Sending mails in a loop using JavaMail API

    Hello All,
    I am sending emails in a loop(one after the other) using JavaMail API,but the problem is, if the first two,three email addresses in the loop are Valid it sends the Email Properly, but if the Fourth or so is Invalid Address it throws an Exception....
    "javax.mail.SendFailedException: Sending failed;"
    nested exception is:
    javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    javax.mail.SendFailedException: 450 <[email protected]>:Recipient address rejected: Domain not found......
    So if i want to send hundereds of emails and if one of the Emails inbetween is Invalid the process Stops at that point and i could not send the other emails in the Loop......
    How Could i Trap the exception thrown and handle it in such a way, so that the loops continues ..
    Is there something with the SMTP Server....?
    The code which i am using is as follows....
    <Code>...
    try {
    InitialContext ic = new InitialContext();
    Session session = (Session) ic.lookup(JNDINames.MAIL_SESSION);
    if (Debug.debuggingOn)
    session.setDebug(true);
    // construct the message
    MimeMessage msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(eMess.getEmailSender()));
    String to = "";
    msg.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse(to, false));
    msg.setRecipients(Message.RecipientType.BCC,
    InternetAddress.parse(eMess.getEmailReceiver(), false));
    msg.setSubject(eMess.getSubject());
    msg.setContent(eMess.getHtmlContents(),"text/plain");
    msg.saveChanges();                
    Transport.send(msg);
    } catch (Exception e) {
    Debug.print("createAndSendMail exception : " + e);
    throw new MailerAppException("Failure while sending mail");
    </Code>....
    Please give me any suggestions regarding it....and guide me accordingly..
    Thanks a million in advance...
    Regards
    Sam

    How about something like the code attached here. Be aware it is lifted and edited out of an app we have here so it may require changing to get it to work. If it don't work - don't come asking for help as this is only a rough example of one way of doing it. RTFM - that's how we worked it out!
    SH
    try {
    Transport.send(msg);
    // If we get to here then the mail went OK so update all the records in the email as sent
    System.out.println("Email sent OK");
    catch (MessagingException mex) {
    System.out.println("Message error");
    Exception ex = mex;
    do {
    if (ex instanceof SendFailedException) {
    if (ex.getMessage().startsWith("Sending failed")) {
    // Ignore this message as we want to know the real reason for failure
    // If we get an Invalid Address error or a Message partially delivered message process the message
    if (ex.getMessage().startsWith("Message partially delivered")
    || ex.getMessage().startsWith("Invalid Addresses")) {
    // This message is of interest as we need to process the actual individual addresses
    System.out.println(ex.getMessage().substring(0, ex.getMessage().indexOf(";")));
    // Now get the addresses from the SendFailedException
    SendFailedException sfex = (SendFailedException) ex;
    Address[] invalid = sfex.getInvalidAddresses();
    if (invalid != null) {
    System.out.println("Invalid Addresse(s) found -");
    if (invalid.length > 0) {
    for (int x = 0; x < invalid.length; x++) {
    System.out.println(invalid[x].toString().trim());
    Address[] validUnsent = sfex.getValidUnsentAddresses();
    if (validUnsent != null) {
    System.out.println("Valid Unsent Addresses found -");
    if (validUnsent.length > 0) {
    for (int x = 0; x < validUnsent.length; x++) {
    System.out.println(validUnsent[x].toString().trim());
    Address[] validSent = sfex.getValidSentAddresses();
    if (validSent != null) {
    System.out.println("Valid Sent Addresses found -");
    if (validSent.length > 0) {
    for (int x = 0; x < validSent.length; x++) {
    System.out.println(validSent[x].toString().trim());
    if (ex instanceof MessagingException)
    ex = ((MessagingException) ex).getNextException();
    else {
    // This is a general catch all and we should assume that no messages went and should stop
    System.out.println(ex.toString());
    throw ex;
    } while (ex != null);

  • Sending Instant Message on Android using Keyboard ...

    Hi Guys,
    I have discovered a potential bug in Skype for Android when sending instant messages. When you click into the box to type a message everything appears as expected. There is a box to type in and to the top right, a smiley (emotion) selector, directly underneath it is a "send" arrow icon.
    When you click into the box and start typing an IM, everything is fine and the send icon remains there. However, when you hit the Enter key, it places a line return in the IM text box and the Send arrow icon disappears. I would expect that the Enter key can be used to send an IM or CTRL+Enter, like in the old MSN days. But more importantly, I would expect at the very least that the Send icon remain.
    Can someone tell me if this is a bug. I replicated this many times, but using the on-screen keyboard and an external keyboard. The device is a 10.1 Galaxy Note.
    I found a similar post here, but that's a different issue.

    Still not fixed! (ASUS tf700t CROMi Xenogenesis 5.1.2)
    The right arrow then touch inside the message box works well for me but ofcourse "enter" or "shift-enter" would be better   I like to be able to use "enter" for a new paragraph so "shift/enter" would be best.

  • Faxing using JavaMail

    Hi,
    Our e-mail server will send faxes through our fax server if you write the address you're sending to in the form
    [FAX:John Smith@02 1234 5678]
    Unfortunately, when I write the line
    InternetAddress toAddress = new InternetAddress("[FAX:John Smith@02 1234 5678]", false);
    I get an error
    javax.mail.internet.AddressException: Illegal address in string ''[FAX:John Smith@02 1234 5678]''
    I thought of subclassing InternetAddress with my own FaxAddress class but InternetAddress's checkAddress method is 'private static void'.
    Does anyone have any ideas?
    Thanks,
    Ian.

    ok..so i was able to retain the entire TO address as it is....
    /name=Test_Suuplier/Fax=91-111-111-1111/ <[email protected]>
    ....using below constructor....
    InternetAddress(java.lang.String address,
    java.lang.String personal,
    java.lang.String charset)
    but now i am getting below error message at the end when sending email.....
    Exception in sending email. Exception javax.mail.internet.AddressException: Missing '<' in string ``"/name=Test_Suuplier/Fax=91-111-111-1111/ <[email protected]>" </name=Test_Suuplier/Fax=91-111-111-1111/ <[email protected]>>'' at position 130. Stack trace: javax.mail.internet.AddressException: Missing '<' in string ``"/name=Test_Suuplier/Fax=91-111-111-1111/ <[email protected]>" </name=Test_Suuplier/Fax=91-111-111-1111/ <[email protected]>>'' at position 130
         at javax.mail.internet.InternetAddress.parse(InternetAddress.java:621)
         at javax.mail.internet.InternetAddress.parse(InternetAddress.java:501)
         at javax.mail.internet.MimeMessage.getAddressHeader(MimeMessage.java:586)
         at javax.mail.internet.MimeMessage.getRecipients(MimeMessage.java:411)
         at javax.mail.Message.getAllRecipients(Message.java:269)
         at javax.mail.internet.MimeMessage.getAllRecipients(MimeMessage.java:426)
         at javax.mail.Transport.send(Transport.java:81)
         at ariba.util.net.BasicEmailClient.send(BasicEmailClient.java:113)
         at ariba.approvable.core.mail.SMTPMailQueueEntry.send(SMTPMailQueue.java:429)
         at ariba.approvable.core.mail.SMTPMailQueue.run(SMTPMailQueue.java:91)
         at ariba.rpc.server.ServerThread.run(ServerThread.java:468)
         at ariba.server.jdbcserver.JDBCServerThread.run(JDBCServerThread.java:314)
         at ariba.base.server.ObjectServerThread.run(ObjectServerThread.java:372)
         at java.lang.Thread.run(Thread.java:534)

  • Sending PP message by FAX

    Hello,
    -Is it possible, like in SD module, to have an automatic PP message with sending by FAX ? I find nothing neither in OPK8 nor directly in CO03.
    -If itu2019s not possible, can we add the FAX sending directly in print program ? (just before the sapscript)
    -Or can we configure a specific printer (SPAD) used in output of a new message ?
    Thanks in advance!

    I am not quite sure if you can send it before it actually creates the spool for printing i.e. in your print program, but do give it a try.
    Alternatively you can evaluate sending the spool as a fax by using FM CONVERT_ABAPSPOOLJOB_2_PDF
    I would suggest discuss both with your technical person who would be in the best position to advice which option suits better.
    Once you get it working do post back your solution so if anyone requires this, can refer to your inputs.

  • Is there a way to make 3g and not wi-fi the priority for sending text messages to someone using an iOS5 device?

    Here's the problem:  I am often in a building which has free wifi but the wifi requires that you accept the terms of use during every browsing session.  If I receive a text message from someone who is also using iOS5, the phone seems to default to wi-fi to send my response.  If I have not yet accepted the terms of use for the building's wi-fi, my phone wont send the text message response.  I don't know if that is because the phone is connected to a wifi signal albeit one that can't yet access the internet.  For whatever reason, the phone is just trapped in a "sending messge" loop and wont break out of it until I open my browser and accept the terms of use.  This is the situation notwithstanding the fact that I have 3g service and the signal is available to send sms/mms.
    Can anyone offer a suggestion other than disabling wi-fi?
    Thanks.

    Thank you for your reply.  I looked at my settings and the phone has been set on "send as SMS"--but for some reason, the phone is continuing to try to send it over wifi despite the lack of an internet connection on wifi.  It would seem that after a minute or more of trying, the phone would recognize that wifi wasnt available and would send it on SMS but it apparently doesnt.  I can, of course, turn off iMessage but I dont like the idea of having to do that everytime---particularly since an increasing number of my contacts are using iOS5 devices.
    Thanks again for your response but it does seem that there is an issue that needs to be addressed.

  • Sending a message to MQSeries using with international characters

    Hello
    I managed to setup oracle messaging gateway to IBM MQSeries. While sending and receiving English message is Fine, sending international characters (8bit Arabic) is received as ??????. I know how to fix this issues when using normal oracle tools. But for the MGW, i cannot find in the documentation where to find the National Language support setting NLS_LANG
    regards

    RESOLVED
    It had nothing to do gateway setting. Actually, it was my mistake. The client environment setting was not correct.
    Once corrected, all went fine
    Ammar

  • Can't send any messages in iChat, used to work perfect though

    I've been having issues with iChat for a while now, I'm using it with AIM, if that helps.
    It shows my buddy list and everything, and shows that I'm connected. I can talk to people over the camera and microphone, but every time I type in something and try to send it, the box with the messages gets deselected, and the messages isn't sent. I've tried restarting my laptop, re-installed iChat, deleted some files out of my library so I can set my AIM account up again, but none of it worked. I hope someone on here can help me...
    Thanks, Peter

    Hi,
    So iChat in Logging in and you are seeing your Buddies in the list ?
    However in any Text Chat text is not being sent ?
    First in iChat > Preferences > Messages check the name of the Font you are using.
    Open Font Book and check it is active.
    I think it will be deeper than this so go to your Home Folder/Library/Preferences and delete com.apple.ichatAgent.plist and restart the computer (iChatAgent is a background app that does not quit when you quit iChat).
    10:49 PM Friday; April 2, 2010
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"

  • How do we Send a noop in imap using javamail?

    Hi all,
    I am running into a situation where I need to keep the session open and using noop to query for any new email, but I couldn't find a command to send NOOP.
    Thanks,
    Grace

    hi
    You can define a o/p and the program will send a email to customer. The program can pick the emails from the customer master or invocie header and send the email.
    The o/p can be connected to the form which wil define the layput of the email.
    Also u can define the condition records and the requirements at output determination so that u can control auto proposing of the o/p
    Reward if helpful
    Kind Regards
    Sandeep

  • How to send Encrypted message using public key in Business Service

    Hi,
    I have one public key (abc.cer) which is given by provider. I have to send encrypted message to Provider using public key. How to achieve it in OSB??
    Thanx
    Edited by: Vinit Ahuja on Jun 16, 2011 3:17 AM

    These are the steps needed to accomplish this:
    1. Import the public certificate in the TrustStore of the OSB Weblogic Server.
    2. Export the public certificate in PEM format. (This will be needed to embed in the custom ws policy)
    3. Create a custom WS policy, with the necessary encryption configuration information. I have placed a sample WS - Policy that I have used @ http://dl.dropbox.com/u/19901533/Sample_Custom_WSPolicy_Encryption.doc for your reference.
    Use a unique value for the wsu:Id in the policy.
    4. Apply this custom policy on the business service in the Request section (assuming you only need to encrypt the request fields)
    5. Activate the changes and then test the business service. You can enable tracing on the BS to validate the encrypted content in the logs.
    Hope this helps.
    Thanks,
    Patrick

  • Tutorial announcement :: How to send a message(s) with attachments ::

    How to send a message with attachments Using Adobe Dreamweaver CS3 and Developer Toolbox...
    - In this tutorial you will use Developer Toolbox features to build a simple contact us form with the advantage to upload file with your message and send this file via e-mail as an attachments.
    Using This application will allow to:
    * insert records into database and then send them via e-mail.
    * upload files to the server.
    * send message with uploaded files as attachments.
    This tutorial contains one part
    1. insert record, and then send it by email with (attachments).
    By following this tutorial section, you will create:
    * Page for inserting records.
    * Page for thank you when the message is sent.
    :: To View the tutorials ::
    :: Online Demo ::
    Brought t you by:
    www.developer-online.com

    Open the photo, assuming it is in Photos, and then in the lower left corner under the photo is a box with an up-pointing arrow.  Tap that box, and then the photo will have a blue circle with a checkmark in its lower right corner and the word Next at the upper right.  Tap Next, then choose how you want to send the photo, by text message, email, and so on.  Simply address the method you have chosen and put in any text you want to include.

  • Sending Process Message from PI Sheets without "Completing" it

    Hi,
    We have long running process orders in our scenarios (typically lasting 3 days).
    We are planning to use PI sheets to manage our goods issue/receipts/confirmations. During the brief evaluation of characteristics based PI sheets, we found that all the GI/GR process messages are created only when the entire PI sheet is "Completed".
    Since ours is a long running process, we need that the GI/GR entered by the operator is posted immediately in the system (without waiting for PI sheet completion). We can not wait till all the data is entered and the process order is completed three days later.
    How do we handle this problem?
    We thought of using custom function modules. However, that will mean that we will loose the benefits of the standard GUI elements of PI sheets and complications of custom development.
    Any response will be highly appreciated.
    Regards,
    Kundan

    Here is something you can try.
    With the browser based sheets, try putting in a signature PI category (SAP provide "SIGN") which tends to create a message and place it in the message monitor.  By scheduling the message send background job to run periodically you can pick up and send the messages.  You can schedule this job to run after the event "NEW MESSAGE" but beware the system performance - every 5 mins or so tends to be almost as good with less strain on system resources!
    I tend to create a table based PI category to contain each reservation plus room to add actual goods issues/receipts.  Once these are entered, a signature category sends all the messages for the particular phase.  Thus good structure of phases is important.
    For goods receipts, you may need to have a phase for each day against which to post a confirmation and/or goods receipt and this together with signature will send the messages.  Alternately, use a PI Category to call the transaction for performing goods receipt - or a bespoke transaction to "front end" the goods receipt - you can pass parameters when you call transactions so you can could pre-populate some information.
    Final point on signature - you can set a simple signature that just accepts whatever the user enters on the screen - typically their initials.
    Regards
    Laurence

Maybe you are looking for