G
Guest
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("(e-mail address removed)","The user"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("(e-mail address removed)","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 in one message!!
Or is there a software to convert my code to C-sharp directly?
Looking forward to hearing from you!!
HishHish
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("(e-mail address removed)","The user"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("(e-mail address removed)","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 in one message!!
Or is there a software to convert my code to C-sharp directly?
Looking forward to hearing from you!!
HishHish