Go Back   Armenian Knowledge Base > Technical sections > Webmaster Zone > Web Development

Reply
 
Thread Tools

Pomogite pojaluysta!
Old 07.02.2005, 09:19   #1
vse naoborot...
 
Katy's Avatar
 
Join Date: 03 2004
Location: Yerevan
Age: 42
Posts: 97
Rep Power: 0
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!

http://vsdi.net/count/down/i/meter-ru32783.png

Old 07.02.2005, 10:32   #2
Угадай
 
Smile's Avatar
 
Join Date: 01 2005
Location: Armenia, Yerevan
Age: 48
Posts: 12
Rep Power: 0
Default

Прив 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. [email protected]): ");
            to = reader.readLine();
            System.out.print("Enter From address (e.g. [email protected]): ");
            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();
        }
    }
}
__________________
просто улыбнись

Old 07.02.2005, 11:38   #3
Угадай
 
Smile's Avatar
 
Join Date: 01 2005
Location: Armenia, Yerevan
Age: 48
Posts: 12
Rep Power: 0
Default

код который я привел думаю что не сработает у тебя (используется спецефическая библиотека), так что в добавок pdf file который детально рассматривает классы и библиотеки для отправки и получения майлов и с аттаяами и без них, которые есть в свободно распростроняющемся J2EE пакете. Так что дерзай :Ճ
__________________
просто улыбнись

Last edited by Smile; 07.02.2005 at 12:46.

Old 09.02.2005, 13:52   #4
vse naoborot...
 
Katy's Avatar
 
Join Date: 03 2004
Location: Yerevan
Age: 42
Posts: 97
Rep Power: 0
Default

ogromnoe spasibo
__________________
Poskol'ku mi jivem v sumasshedshem mire, nam samim nujno bit' nemnogo sumasshedshimi!

http://vsdi.net/count/down/i/meter-ru32783.png
Reply




Реклама:
реклама
Buy text link .

All times are GMT. The time now is 08:10.
Top

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.