mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 11:12:22 -05:00
Build message name from subject on create
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@307 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
1fd0964f78
commit
091ddc244f
@ -449,6 +449,15 @@ public class ExchangeSession {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace invalid url chars
|
||||||
|
* @param subject
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected String encodeSubject(String subject) {
|
||||||
|
return subject.replaceAll("/", "_xF8FF_").replaceAll("\\?", "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create message in specified folder.
|
* Create message in specified folder.
|
||||||
* Will overwrite an existing message with same subject in the same folder
|
* Will overwrite an existing message with same subject in the same folder
|
||||||
@ -461,7 +470,7 @@ public class ExchangeSession {
|
|||||||
* @throws java.io.IOException when unable to create message
|
* @throws java.io.IOException when unable to create message
|
||||||
*/
|
*/
|
||||||
public void createMessage(String folderUrl, String messageName, String bcc, String messageBody, boolean allowOverwrite) throws IOException {
|
public void createMessage(String folderUrl, String messageName, String bcc, String messageBody, boolean allowOverwrite) throws IOException {
|
||||||
String messageUrl = URIUtil.encodePathQuery(folderUrl + "/" + messageName + ".EML");
|
String messageUrl = URIUtil.encodePathQuery(folderUrl + "/" + encodeSubject(messageName) + ".EML");
|
||||||
|
|
||||||
PutMethod putmethod = new PutMethod(messageUrl);
|
PutMethod putmethod = new PutMethod(messageUrl);
|
||||||
putmethod.setRequestHeader("Translate", "f");
|
putmethod.setRequestHeader("Translate", "f");
|
||||||
|
@ -287,7 +287,19 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
}
|
}
|
||||||
// empty line
|
// empty line
|
||||||
readClient();
|
readClient();
|
||||||
session.createMessage(session.getFolderPath(folderName), "test", null, new String(buffer), true);
|
String messageBody = new String(buffer);
|
||||||
|
String subject = null;
|
||||||
|
int subjectStartIndex = messageBody.indexOf("Subject: ");
|
||||||
|
if (subjectStartIndex >= 0) {
|
||||||
|
int subjectEndIndex = messageBody.indexOf("\r", subjectStartIndex);
|
||||||
|
if (subjectEndIndex >= 0) {
|
||||||
|
subject = messageBody.substring(subjectStartIndex+"Subject: ".length(), subjectEndIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (subject == null) {
|
||||||
|
subject = "mail"+System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
session.createMessage(session.getFolderPath(folderName), subject, null, new String(buffer), true);
|
||||||
sendClient(commandId + " OK APPEND completed");
|
sendClient(commandId + " OK APPEND completed");
|
||||||
} else if ("noop".equalsIgnoreCase(command)) {
|
} else if ("noop".equalsIgnoreCase(command)) {
|
||||||
if (currentFolder != null) {
|
if (currentFolder != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user