Jump to content
Sign in to follow this  
BudaK-MalaS

Tulun Aku Jap..

Recommended Posts

korang blet tulun x..?

camana nak buat button send tu bley send ape aku tulis kat email..?

plz adjust coding tu..

urgent nie...

import javax.swing.*;

import java.awt.*;

public class WriteMail extends JFrame {

public WriteMail() {

super("registration Subjects");

setSize(370, 270);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

FlowLayout flow = new FlowLayout(FlowLayout.RIGHT);

setLayout(flow);

JPanel row1 = new JPanel();

JLabel toLabel = new JLabel("To:");

row1.add(toLabel);

JTextField to = new JTextField(24);

row1.add(to);

add(row1);

JPanel row2 = new JPanel();

JLabel subjectLabel = new JLabel("Subject:");

row2.add(subjectLabel);

JTextField subject = new JTextField(24);

row2.add(subject);

add(row2);

JPanel row3 = new JPanel();

JLabel messageLabel = new JLabel("Message:");

row3.add(messageLabel);

JTextArea message = new JTextArea(4, 22);

message.setLineWrap(true);

message.setWrapStyleWord(true);

JScrollPane scroll = new JScrollPane(message,

JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,

JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

row3.add(scroll);

add(row3);

JPanel row4 = new JPanel();

JButton send = new JButton("Send");

row4.add(send);

add(row4);

setVisible(true);

}

public static void main(String[] arguments){

WriteMail mail = new WriteMail();

}

}

Share this post


Link to post
Share on other sites

aku xpaham la bro..

koding tu nak letak kat mana?

Share this post


Link to post
Share on other sites

mail server tu nak letak kat mana..?

sori..aku mmg xtau nih..

Share this post


Link to post
Share on other sites

Ko kena letak action listener kat button send tu. Java mail tu buat 1 class. Letak kat actionListener. Ko kena tau mail server pe yang ko nk send pe yang ko dah tulis dalam kotak gui ko tu. Kalo tak tau mail ape, memang tak sampai ape yang ko nak send tu.

ActionListener

Edited by Firestarter

Share this post


Link to post
Share on other sites

bro...

java email example tu, nak save kat dlm folder bin jdk atau jre..?

aku dah download API tu tp xreti nak simpan kat mana...

Share this post


Link to post
Share on other sites

ok, skang ni ko keje atau student lagi? kalau keje, biasa company ko da siap2 ada mail server da..

kalau ko blaja lagi, boleh try pakai yang free nye

Share this post


Link to post
Share on other sites

sori korang..

aku student lagi..

aku mmg xpaham pun..

aku blaja cuma dpt table, pastu buat coding..

tup tup..kena buat projek guna GUI..

giler btol..

tq sbb membantu...

syg kat korang..

hidup PUTERA..!!

Share this post


Link to post
Share on other sites

ni contoh cmne nk masukkn koding tu dalam button ko...

leftButton = new JButton( "OK" );
container.add( leftButton );
leftButton.addActionListener(

new ActionListener(){
public void actionPerformed( ActionEvent event )
{
<buat la apa ko nk kt cni>
layout.layoutContainer( container );
}
}
);

ok nmpk tk?

Share this post


Link to post
Share on other sites

ni contoh cmne nk masukkn koding tu dalam button ko...

leftButton = new JButton( "OK" );
container.add( leftButton );
leftButton.addActionListener(

new ActionListener(){
public void actionPerformed( ActionEvent event )
{
<buat la apa ko nk kt cni>
layout.layoutContainer( container );
}
}
);

ok nmpk tk?

jap..

klik button kat netbeans tu,k pastu paste coding nie ker..?

yg nie plak ape --> "buat la apa ko nk kt cni".. bley bagi contoh..?

Share this post


Link to post
Share on other sites

Ko tak buat rujukan mana2 web ke? Ada tak ko pegi kat sun punya site tu? Pilih API dokumentasi. Situ banyak bagitau tutorial.

Tempat <buat la apa ko nk kt cni> tu, ko nak panggil class yang ko buat mail tadi(tak tau la ko paham ke tak). Bila ko dah panggil baru la button tu buleh berfungsi dengan betol.

Nanti aku bagi PM kat ko..Pasal Java ni..Banyak yang ko nak kena tau walaupun ko buat projek kecil je.

Share this post


Link to post
Share on other sites

import java.io.*;

import javax.mail.*;

import javax.mail.internet.*;

import javax.activation.*;

public class SendApp {

public static void send(String smtpHost, int smtpPort,

String from, String to,

String subject, String content)

throws AddressException, MessagingException {

// Create a mail session

java.util.Properties props = new java.util.Properties();

props.put("mail.smtp.host", smtpHost);

props.put("mail.smtp.port", ""+smtpPort);

Session session = Session.getDefaultInstance(props, null);

// Construct the message

Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(from));

msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));

msg.setSubject(subject);

msg.setText(content);

// Send the message

Transport.send(msg);

}

public static void main(String[] args) throws Exception {

// Send a test message

send("hostname", 25, "[email protected]", "[email protected]",

"re: dinner", "How about at 7?");

}

}

aku guna netbeans, ade prob kat

import javax.activation.*;

public class SendApp {

so camana ek..

cpt2..dah nazak sgt nih..

Share this post


Link to post
Share on other sites

tq korang sbb sudi membantu..

aku berjaya wat sistem yg cikai dengaan hasil bantuan korang..

kejayaan nie bkn untuk aku jer, tp untuk korang yg berjaya ajar aku..

tq byk2...

muah..muah..muah..

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...