|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: |
java code
import java.util.Date;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
public class Main {
public void sendMail(String toemail, String subject, String body, String messageBody,String[] file)
throws MessagingException {
String host = "mail.abc.com";
String user = "info@abc.com";
String pass = "abc";
// Create properties, get Session
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol.", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.", "true");
props.put("mail.smtp.port", "2525");
props.put("mail.smtp.socketFactory.fallback", "false");
Session mailSession = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(user));
InternetAddress[] address = { new InternetAddress(toemail) };
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(body);
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(messageBody);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
addAtachments(file, multipart);
msg.setContent(multipart);
Transport transport = mailSession.getTransport("smtp");
transport.connect(host, user, pass);
transport.sendMessage(msg,msg.getAllRecipients());
transport.close();
}
protected void addAtachments(String[] attachments, Multipart multipart)
throws MessagingException, AddressException
{
for(int i = 0; i<= attachments.length -1; i++ )
{
String filename = attachments[i];
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
attachmentBodyPart.setDataHandler(new DataHandler(source));
attachmentBodyPart.setFileName("a.gif");
multipart.addBodyPart(attachmentBodyPart);
}
}
}
flex 4 code
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768" xmlns:mk="services.mk.*" xmlns:fgg="services.fgg.*" xmlns:gett="services.gett.*">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
protected function button_clickHandler(event:MouseEvent):void
{
sendMailResult.token = gett.sendMail(arg0TextInput.text,arg1TextInput.text,arg2TextInput.text,arg3TextInput.text,new ArrayCollection());
}
]]>
</fx:Script>
<fx:Declarations>
<gett:Gett id="gett" destination="mailaa" endpoint="http://localhost:8400/Project/messagebroker/amf" fault="Alert.show(event.fault.faultString)" showBusyCursor="true" source="Main"/>
<s:CallResponder id="sendMailResult"/>
</fx:Declarations>
<mx:Form defaultButton="{button}">
<mx:FormItem label="Arg0">
<s:TextInput id="arg0TextInput"/>
</mx:FormItem>
<mx:FormItem label="Arg1">
<s:TextInput id="arg1TextInput"/>
</mx:FormItem>
<mx:FormItem label="Arg2">
<s:TextInput id="arg2TextInput"/>
</mx:FormItem>
<mx:FormItem label="Arg3">
<s:TextInput id="arg3TextInput"/>
</mx:FormItem>
<s:Button label="SendMail" id="button" click="button_clickHandler(event)"/>
</mx:Form>
</s:Application>
|
Advertisement
| Hall of Fame |