Skip to content

Commit 6fc552b

Browse files
committed
Restructure Aspose.Email Java for Apache POI
1 parent 0bdadcd commit 6fc552b

File tree

51 files changed

+975
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+975
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.aspose</groupId>
5+
<artifactId>email-java</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<maven.compiler.source>1.7</maven.compiler.source>
10+
<maven.compiler.target>1.7</maven.compiler.target>
11+
</properties>
12+
<dependencies>
13+
<dependency>
14+
<groupId>com.aspose</groupId>
15+
<artifactId>aspose-email</artifactId>
16+
<version>5.5.0</version>
17+
<classifier>jdk16</classifier>
18+
</dependency>
19+
<dependency>
20+
<groupId>com.aspose</groupId>
21+
<artifactId>aspose-words</artifactId>
22+
<version>15.6.0</version>
23+
<classifier>jdk16</classifier>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.apache.poi</groupId>
27+
<artifactId>poi</artifactId>
28+
<version>3.11</version>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.apache.poi</groupId>
32+
<artifactId>poi-scratchpad</artifactId>
33+
<version>3.11</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>javax.media.jai</groupId>
37+
<artifactId>com.springsource.javax.media.jai.core</artifactId>
38+
<version>1.1.3</version>
39+
</dependency>
40+
</dependencies>
41+
<repositories>
42+
<repository>
43+
<id>aspose-maven-repository</id>
44+
<url>http://maven.aspose.com/repository/repo/</url>
45+
</repository>
46+
<repository>
47+
<id>com.springsource.repository.bundles.external</id>
48+
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
49+
<url>http://repository.springsource.com/maven/bundles/external</url>
50+
</repository>
51+
</repositories>
52+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.aspose.email.examples;
2+
3+
import java.io.File;
4+
5+
public class Utils {
6+
7+
public static String getDataDir(Class c) {
8+
File dir = new File(System.getProperty("user.dir"));
9+
dir = new File(dir, "src");
10+
dir = new File(dir, "main");
11+
dir = new File(dir, "resources");
12+
13+
for (String s : c.getName().split("\\.")) {
14+
dir = new File(dir, s);
15+
if (dir.isDirectory() == false)
16+
dir.mkdir();
17+
}
18+
19+
System.out.println("Using data directory: " + dir.toString());
20+
return dir.toString() + File.separator;
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.aspose.email.examples.asposefeatures.appointments.addattachmentstocalenderitems;
2+
3+
import java.io.File;
4+
import java.io.FileInputStream;
5+
import java.util.Calendar;
6+
import java.util.Date;
7+
import java.util.TimeZone;
8+
9+
import com.aspose.email.Appointment;
10+
import com.aspose.email.AppointmentSaveFormat;
11+
import com.aspose.email.Attachment;
12+
import com.aspose.email.MailAddress;
13+
import com.aspose.email.MailAddressCollection;
14+
import com.aspose.email.WeeklyRecurrencePattern;
15+
import com.aspose.email.examples.Utils;
16+
17+
public class AsposeAddAttachmentToCalenderItems
18+
{
19+
public static void main(String[] args) throws Exception
20+
{
21+
// The path to the documents directory.
22+
String dataDir = Utils.getDataDir(AsposeAddAttachmentToCalenderItems.class);
23+
24+
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
25+
calendar.set(2012, Calendar.NOVEMBER, 1, 0, 0, 0);
26+
Date startDate = calendar.getTime();
27+
calendar.set(2012, Calendar.DECEMBER, 1);
28+
Date endDate = calendar.getTime();
29+
30+
MailAddressCollection attendees = new MailAddressCollection();
31+
attendees.addItem(new MailAddress("[email protected]", "Attendee"));
32+
WeeklyRecurrencePattern expected = new WeeklyRecurrencePattern(3);
33+
34+
Appointment app = new Appointment("Appointment Location", "Appointment Summary", "Appointment Description",
35+
startDate, endDate,
36+
new MailAddress("[email protected]", "Organizer"), attendees, expected);
37+
38+
//Attach a file from disc to this appointment
39+
File file = new File(dataDir + "AsposeXLS.xls");
40+
FileInputStream fis = new FileInputStream(file);
41+
42+
Attachment att = new Attachment(fis, file.getName());
43+
app.getAttachments().addItem(att);
44+
fis.close();
45+
46+
String savedFile = dataDir + "AppWithAttachments.ics";
47+
app.save(savedFile, AppointmentSaveFormat.Ics);
48+
49+
System.out.println("Done.");
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.aspose.email.examples.asposefeatures.appointments.colorcategory;
2+
3+
import com.aspose.email.FollowUpManager;
4+
import com.aspose.email.MailMessageSaveType;
5+
import com.aspose.email.MapiMessage;
6+
import com.aspose.email.system.collections.IList;
7+
import com.aspose.email.examples.Utils;
8+
9+
public class AsposeCategory
10+
{
11+
public static void main(String[] args)
12+
{
13+
// The path to the documents directory.
14+
String dataDir = Utils.getDataDir(AsposeCategory.class);
15+
16+
MapiMessage msg = MapiMessage.fromFile(dataDir + "message.msg");
17+
// Add category
18+
FollowUpManager.addCategory(msg, "Purple Category");
19+
20+
// Add another category
21+
FollowUpManager.addCategory(msg, "Red Category");
22+
23+
// Retrieve the list of available categories
24+
IList categories = FollowUpManager.getCategories(msg);
25+
26+
// Remove the specified category
27+
FollowUpManager.removeCategory(msg, "Red Category");
28+
29+
// Clear all categories
30+
//FollowUpManager.clearCategories(msg);
31+
32+
msg.save(dataDir + "AsposeCategories.msg");
33+
34+
System.out.println("Done");
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.aspose.email.examples.asposefeatures.appointments.createcalenderitem;
2+
3+
import java.util.Date;
4+
5+
import com.aspose.email.AppointmentSaveFormat;
6+
import com.aspose.email.MapiCalendar;
7+
import com.aspose.email.examples.Utils;
8+
9+
public class AsposeNewCalenderItems
10+
{
11+
public static void main(String[] args) throws Exception
12+
{
13+
// The path to the documents directory.
14+
String dataDir = Utils.getDataDir(AsposeNewCalenderItems.class);
15+
16+
// Create the appointment
17+
MapiCalendar appointment = new MapiCalendar(
18+
"LAKE ARGYLE WA 6743",
19+
"Appointment",
20+
"This is a very important meeting :)",
21+
new Date(2012, 10, 2, 13, 0, 0),
22+
new Date(2012, 10, 2, 14, 0, 0));
23+
24+
appointment.save(dataDir + "AsposeCalendarItem.ics", AppointmentSaveFormat.Ics);
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.aspose.email.examples.asposefeatures.appointments.formattingappointment;
2+
3+
import com.aspose.email.Appointment;
4+
import com.aspose.email.AppointmentFormattingOptions;
5+
import com.aspose.email.examples.Utils;
6+
7+
public class AsposeFormatAppointments
8+
{
9+
public static void main(String[] args)
10+
{
11+
// The path to the documents directory.
12+
String dataDir = Utils.getDataDir(AsposeFormatAppointments.class);
13+
14+
Appointment appointment = Appointment.load(dataDir + "appointment.ics");
15+
AppointmentFormattingOptions formattingOptions = new AppointmentFormattingOptions();
16+
formattingOptions.setLocationFormat("Where: {0}");
17+
formattingOptions.setTitleFormat("Subject: {0}");
18+
formattingOptions.setDescriptionFormat("\r\n*~*~*~*~*~*~*~*~*~*\r\n{0}");
19+
System.out.println(appointment.getAppointmentText(formattingOptions));
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.aspose.email.examples.asposefeatures.appointments.getattachmentsfromcalender;
2+
3+
import com.aspose.email.Appointment;
4+
import com.aspose.email.Attachment;
5+
import com.aspose.email.examples.Utils;
6+
7+
public class AsposeGetAttachmentsFromCalender
8+
{
9+
public static void main(String[] args)
10+
{
11+
// The path to the documents directory.
12+
String dataDir = Utils.getDataDir(AsposeGetAttachmentsFromCalender.class);
13+
14+
String savedFile = dataDir + "AppWithAttachments.ics";
15+
16+
Appointment app2 = Appointment.load(savedFile);
17+
System.out.println("Total Attachments: " + app2.getAttachments().size());
18+
for (int i=0; i< app2.getAttachments().size();i++)
19+
{
20+
Attachment att = app2.getAttachments().get_Item(i);
21+
System.out.println(att.getName());
22+
23+
//Save the attachment to disc
24+
att.save(dataDir + att.getName());
25+
}
26+
27+
System.out.println("Done");
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.aspose.email.examples.asposefeatures.conversion.msgtootherformats;
2+
3+
import com.aspose.email.MailMessage;
4+
import com.aspose.email.MailMessageSaveType;
5+
import com.aspose.email.MessageFormat;
6+
import com.aspose.email.examples.Utils;
7+
8+
public class AsposeConverter
9+
{
10+
public static void main(String[] args)
11+
{
12+
// The path to the documents directory.
13+
String dataDir = Utils.getDataDir(AsposeConverter.class);
14+
15+
// Initialize and Load an existing MSG file by specifying the MessageFormat
16+
MailMessage msg = MailMessage.load(dataDir + "message.msg");
17+
18+
// Save the Email message to disk
19+
msg.save(dataDir + "AsposeMessage.eml");
20+
msg.save(dataDir + "Asposemessage.mhtml");
21+
22+
System.out.println("Done");
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.aspose.email.examples.asposefeatures.conversion.osttopst;
2+
3+
import com.aspose.email.FileFormat;
4+
import com.aspose.email.PersonalStorage;
5+
import com.aspose.email.examples.Utils;
6+
7+
public class AsposeOSTtoPST
8+
{
9+
public static void main(String[] args)
10+
{
11+
// The path to the documents directory.
12+
String dataDir = Utils.getDataDir(AsposeOSTtoPST.class);
13+
14+
PersonalStorage ost = PersonalStorage.fromFile(dataDir + "outlook.ost");
15+
16+
ost.saveAs(dataDir + "AsposeOST-PST.pst", FileFormat.Pst);
17+
System.out.println("Done");
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.aspose.email.examples.asposefeatures.conversion.savemessageaspdf;
2+
3+
import java.io.ByteArrayInputStream;
4+
import java.io.ByteArrayOutputStream;
5+
import java.io.FileInputStream;
6+
7+
import com.aspose.email.MailMessage;
8+
import com.aspose.email.SaveOptions;
9+
import com.aspose.words.Document;
10+
import com.aspose.words.LoadFormat;
11+
import com.aspose.words.LoadOptions;
12+
import com.aspose.words.SaveFormat;
13+
14+
import com.aspose.email.examples.Utils;
15+
16+
public class AsposeSaveMessageAsPDF
17+
{
18+
public static void main(String[] args) throws Exception
19+
{
20+
// The path to the documents directory.
21+
String dataDir = Utils.getDataDir(AsposeSaveMessageAsPDF.class);
22+
23+
FileInputStream fstream = new FileInputStream(dataDir + "message.msg");
24+
MailMessage eml = MailMessage.load(fstream);
25+
26+
// Save the Message to output stream in MHTML format
27+
ByteArrayOutputStream emlStream = new ByteArrayOutputStream();
28+
eml.save(emlStream, SaveOptions.getDefaultMhtml());
29+
30+
// Load the stream in Word document
31+
LoadOptions lo = new LoadOptions();
32+
lo.setLoadFormat(LoadFormat.MHTML);
33+
Document doc = new Document(new ByteArrayInputStream(
34+
emlStream.toByteArray()), lo);
35+
36+
// Save to disc
37+
doc.save(dataDir + "About Aspose.Pdf", SaveFormat.PDF);
38+
39+
// or Save to stream
40+
ByteArrayOutputStream foStream = new ByteArrayOutputStream();
41+
doc.save(foStream, SaveFormat.PDF);
42+
43+
System.out.println("Done");
44+
}
45+
}

0 commit comments

Comments
 (0)