AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters > Web Development
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Web Development Java/PHP/Perl/ASP and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Feb 7, 2005, 08:19   #1
vse naoborot...
 
Katy's Avatar
 
Join Date: Mar 2004
Location: Yerevan
Posts: 97
Rep Power: 0
Reputation: 10
Send a message via ICQ to Katy
Question Pomogite pojaluysta!

Ya navichek v Java i u menya takoy vopros: kak ya mogu iz Java sgenerirovat' outlook mail, s imeushimisya dannimi: e-mail address-om i attachment-om.. pojaluysta posovetuyte gde ya mogu nayti informaciu o classax, kotorie ispol'zuyutsya v reshenii takogo roda zadach' (dumayu, chto takie classi doljni imetsya ). Zaranee blagodaru
__________________
Poskol'ku mi jivem v sumasshedshem mire, nam samim nujno bit' nemnogo sumasshedshimi!

Katy is offline   Reply With Quote Quote selected
Old Feb 7, 2005, 09:32   #2
Угадай
 
Smile's Avatar
 
Join Date: Jan 2005
Location: Armenia, Yerevan
Posts: 12
Rep Power: 0
Reputation: 10
Прив Katy, ниже приведенный код думаю поможет

Код демонстрирует как отправлять маилики с аттачами используя SMTP компоненты
Code:
import com.jscape.inet.smtp.*;
import com.jscape.inet.mime.*;
import com.jscape.inet.email.*;
import java.io.*;

public class SmtpAttachmentExample extends SmtpAdapter {
    public void sendMessage(String hostname, String to, String from, String subject, String body, String attachment) throws SmtpException, 
    IOException, MimeException {
      
      // create new Smtp instance
        Smtp smtp = new Smtp(hostname);
        
        // enable debugging
        smtp.setDebug(true);
        
        // register this class to capture SMTP related events
        smtp.addSmtpListener(this);
        
        // connect to SMTP server
        smtp.connect();
        
        // create email message
        EmailMessage email = new EmailMessage();
        email.setTo(to);
        email.setFrom(from);
        email.setSubject(subject);
        email.setBody(body);
        
        // add attachment to email message
        email.addAttachment(new Attachment(new File(attachment)));
        
        // send email message
        smtp.send(email);
        
        // disconnect from SMTP server
        smtp.disconnect();
    }
    
    // capture connect event
    public void connected(SmtpConnectedEvent evt) {
        System.out.println("Connected to SMTP server: " + evt.getHostname());
    }
    
    // capture disconnect event
    public void disconnected(SmtpDisconnectedEvent evt) {
        System.out.println("Disconnected from SMTP server: " + evt.getHostname());
    }
    
    public static void main(String[] args) {
        String hostname;
        String to;
        String from;
        String subject;
        String body;
        String attach;
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            System.out.print("Enter SMTP hostname (e.g. mail.domain.com): ");
            hostname = reader.readLine();
            System.out.print("Enter To address (e.g. recipient@domain.com): ");
            to = reader.readLine();
            System.out.print("Enter From address (e.g. sender@domain.com): ");
            from = reader.readLine();
            subject = "iNet Factory Attachment Example";
            body = "see attached image";
            attach = "image.gif";
            SmtpAttachmentExample example = new SmtpAttachmentExample();
            example.sendMessage(hostname,to,from,subject,body,attach);
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}
__________________
просто улыбнись
Smile is offline   Reply With Quote Quote selected
Old Feb 7, 2005, 10:38   #3
Угадай
 
Smile's Avatar
 
Join Date: Jan 2005
Location: Armenia, Yerevan
Posts: 12
Rep Power: 0
Reputation: 10
код который я привел думаю что не сработает у тебя (используется спецефическая библиотека), так что в добавок pdf file который детально рассматривает классы и библиотеки для отправки и получения майлов и с аттаяами и без них, которые есть в свободно распростроняющемся J2EE пакете. Так что дерзай :Ճ
Attached Images
File Type: pdf J2EE_mail_for_Katy.pdf (290.8 KB, 87 views)
__________________
просто улыбнись

Last edited by Smile : Feb 7, 2005 at 11:46.
Smile is offline   Reply With Quote Quote selected
Old Feb 9, 2005, 12:52   #4
vse naoborot...
 
Katy's Avatar
 
Join Date: Mar 2004
Location: Yerevan
Posts: 97
Rep Power: 0
Reputation: 10
Send a message via ICQ to Katy
ogromnoe spasibo
__________________
Poskol'ku mi jivem v sumasshedshem mire, nam samim nujno bit' nemnogo sumasshedshimi!

Katy is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pomogite :) Mulik MusiCity 13 Jan 11, 2005 12:17
Pomogite nayti Mulik History and Politics 5 Aug 22, 2004 05:37
Pomogite pojaluista naiti nazvanie pesni.... DaNYer General 13 Oct 19, 2002 04:37
pomogite najti Referat pro Mesropa Mashtoca!!!! _MiLord_ General 8 Sep 19, 2002 22:30
Pomogite nayti knigu plz! Gayka Literary nook 2 Jul 31, 2002 17:07


All times are GMT. The time now is 19:27.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link