* @param fromName
* @param toName
*/
public static void writeEchomail(Echoarea area, String subject,
String text, String fromName, String toName) {
Echomail mail = new Echomail();
mail.setFromFTN(getPrimaryFtnAddress().toString());
mail.setFromName(fromName);
mail.setArea(area);
mail.setDate(new Date());
mail.setPath("");
mail.setSeenBy("");
mail.setToName(toName);
mail.setSubject(subject);
mail.setMsgid(getPrimaryFtnAddress().toString() + " "
+ FtnTools.generate8d());
StringBuilder b = new StringBuilder();
b.append(String.format("\001PID: %s\n\001TID: %s\n\n",
MainHandler.getVersion(), MainHandler.getVersion()));
b.append(text);
b.append("\n--- "
+ MainHandler.getCurrentInstance().getInfo().getStationName()
+ "\n");
b.append(" * Origin: " + MainHandler.getVersion() + " ("
+ getPrimaryFtnAddress().toString() + ")\n");
mail.setText(b.toString());
ORMManager.get(Echomail.class).save(mail);
if (mail.getId() != null) {
for (Subscription s : ORMManager.get(Subscription.class).getAnd(
"echoarea_id", "=", area)) {
ORMManager.get(EchomailAwaiting.class).save(
new EchomailAwaiting(s.getLink(), mail));
}