Hi, I have a Java code that I want to convert it to C-sharp in order to put it in my ASP.NET web application. I used the JLCA (Java Language Conversion Assistant) for conversion, but it gave me many errors indicating that there are not matches in .NET for those
Java classes!! The Java code is: ***************************************************************** import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class Sender { public static void main(String
[] args) { try { Properties props = System.getProperties(); props.put("mail.smtp.host","localhost"); Session session = Session.getDefaultInstance(props,null); session.setDebug(true); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("user@host.net","The
user")); message.addRecipient(Message.RecipientType.TO, new InternetAddress("user2@host2.com","User2")); message.addHeader("Mime-Version","1.0"); MimeMultipart multipart = new MimeMultipart("related"); message.setContent(multipart); message.writeTo(System.out);
MimeBodyPart messageBodyPart = new MimeBodyPart(); //Part 1 DataSource source = new FileDataSource("d:\\mmw\\real_logo.jpg"); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setHeader("Content-ID", "real_logo.jpg"); messageBodyPart.setFileName("real_logo.jpg");
multipart.addBodyPart(messageBodyPart); //Part 2 messageBodyPart = new MimeBodyPart(); source = new FileDataSource("d:\\mmw\\hi.txt"); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setHeader("Content-ID", "hi.txt"); messageBodyPart.setFileName("hi.txt");
multipart.addBodyPart(messageBodyPart); Transport.send(message); } catch(Exception e){System.err.println(""+e);} } } ***************************************************************** Does anyone know the equivalent C-sharp code? i.e, I need to make more than
1 mime part with different content-types and content-ids!! Or is there a software to convert my code to C-sharp directly? Looking forward to hearing from you!! HishHish
HishHish
Member
5 Points
1 Post
How to write Mime messages in C-sharp?
May 03, 2004 12:59 PM|LINK
KraGiE
Star
14567 Points
2926 Posts
Re: How to write Mime messages in C-sharp?
Jun 15, 2004 09:13 PM|LINK