× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



This is a multi-part message in MIME format.
--
Dear Sir I am ready to send you the source code of My Program. Please check
that and run it as it does not appear to be any problem but access denied to
send from the SMTP server. Please did something for my favour i am really
thankful for that. Actually i have been due SERVLET Virtual UNIVERSITY from
my advisor and it have a part to send email notification to my Registered
Members. but when i tried simplest example but it doest not send that and
gives run time exception of access denied. Plz see on my code and suggest to
me that what to do by me. I am really thxful for that. Please gives me quick
response I am already to late.Thx
Tariq Mahmood





_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
--
import javax.mail.*;
import javax.activation.*;
import javax.mail.internet.*;
import java.util.*;

  /* A simple email sender class. */

public class EmailNotificatio
{

  public static void send(String smtpServer, String to, String from, String
subject, String body)
  {
    try
    {
      Properties props = System.getProperties();

      // -- Attaching to default Session, or we could start a new one --

      props.put("mail.smtp.host", smtpServer);
      Session session = Session.getDefaultInstance(props, null);


      // -- Create a new message --
      Message msg = new MimeMessage(session);

      // -- Set the FROM and TO fields --
      msg.setFrom(new InternetAddress(from));
      msg.setRecipients(Message.RecipientType.TO,
        InternetAddress.parse(to, false));

      // -- We could include CC recipients too --
      // if (cc != null)
      // msg.setRecipients(Message.RecipientType.CC
      // ,InternetAddress.parse(cc, false));

      // -- Set the subject and body text --
      msg.setSubject(subject);
      msg.setText(body);

      // -- Set some other header information --
      msg.setHeader("X-Mailer", "LOTONtechEmail");
      msg.setSentDate(new Date());

      // -- Send the message --
      Transport.send(msg);

      System.out.println("Message sent OK.");
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
  }



  public static void main(String args[])
  {
    try
    {
      String smtpServer=args[0];//smtp.wol.net.pk
      String to=args[1];
      String from=args[2];
      String subject=args[3];
      String body=args[4];
      send(smtpServer, to, from, subject, body);
    }

    catch (Exception ex)
    {
     System.out.println("Usage: java com.lotontech.mail.SimpleSender
smtpServer toAddress fromAddress subjectText bodyText");
     }

    System.exit(0);
  }

}


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.