Re: Parse .eml files

2018-04-12 Thread Martin Tschierschke via Digitalmars-d-learn

On Thursday, 12 April 2018 at 00:00:04 UTC, bachmeier wrote:
On Wednesday, 11 April 2018 at 15:20:08 UTC, Martin 
Tschierschke wrote:


My question in the moment is, how do I invoke Thunderbird to 
display a certain single mail (or maildir) file?
How do I use Thunderbird as the client, to show, to answer or 
to forward these mails.
An alternative would be to use a browser based mailer? 
Handling all attachments is an other purpose.


Can you use executeShell and call Thunderbird from the command 
line? Something like


executeShell("thunderbird -compose \"subject='My Christmas 
Gift',body='Please send me a new car',to='sa...@claus.net'")


http://kb.mozillazine.org/Command_line_arguments_%28Thunderbird%29


Thank you, especially for the Link!
There I saw, that attachment with a local file is possible. So It 
should be possible to invoke Thunderbird with the extracted 
elements of an existing email.




Re: Parse .eml files

2018-04-11 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 15:20:08 UTC, Martin Tschierschke 
wrote:


My question in the moment is, how do I invoke Thunderbird to 
display a certain single mail (or maildir) file?
How do I use Thunderbird as the client, to show, to answer or 
to forward these mails.
An alternative would be to use a browser based mailer? Handling 
all attachments is an other purpose.


Can you use executeShell and call Thunderbird from the command 
line? Something like


executeShell("thunderbird -compose \"subject='My Christmas 
Gift',body='Please send me a new car',to='sa...@claus.net'")


http://kb.mozillazine.org/Command_line_arguments_%28Thunderbird%29


Re: Parse .eml files

2018-04-11 Thread Martin Tschierschke via Digitalmars-d-learn

On Wednesday, 11 April 2018 at 02:37:39 UTC, bachmeier wrote:

On Monday, 9 April 2018 at 19:17:20 UTC, Adam D. Ruppe wrote:

[...]

I had a chance to try this out and it worked without a problem. 
I did have to download color.d in addition to the other 
dependencies you listed. In the event that Google brings 
someone here, this is a complete working program:


import std.file, std.stdio, std.string;
import arsd.email;

void main(string[] args) {
  string[] f = std.file.readText(args[1]).splitLines();
  auto em = new IncomingEmailMessage(f);
  writeln("From: ", em.from);
  writeln("To: ", em.to);
  writeln("Subject: ", em.subject);
  writeln(em.textMessageBody);
}

Compile with

dmd *.d -ofreademail

And run

./reademail 'email message.eml'


Very cool, I was looking for something similar, thank you both 
for sharing!


My goal is to store mails in a mysql table with fulltext index, 
connected to a existing old crm solution via the email address as 
a foreign key.


My question in the moment is, how do I invoke Thunderbird to 
display a certain single mail (or maildir) file?
How do I use Thunderbird as the client, to show, to answer or to 
forward these mails.
An alternative would be to use a browser based mailer? Handling 
all attachments is an other purpose.





Re: Parse .eml files

2018-04-10 Thread bachmeier via Digitalmars-d-learn

On Monday, 9 April 2018 at 19:17:20 UTC, Adam D. Ruppe wrote:

[...]

I had a chance to try this out and it worked without a problem. I 
did have to download color.d in addition to the other 
dependencies you listed. In the event that Google brings someone 
here, this is a complete working program:


import std.file, std.stdio, std.string;
import arsd.email;

void main(string[] args) {
  string[] f = std.file.readText(args[1]).splitLines();
  auto em = new IncomingEmailMessage(f);
  writeln("From: ", em.from);
  writeln("To: ", em.to);
  writeln("Subject: ", em.subject);
  writeln(em.textMessageBody);
}

Compile with

dmd *.d -ofreademail

And run

./reademail 'email message.eml'



Re: Parse .eml files

2018-04-09 Thread bachmeier via Digitalmars-d-learn

On Monday, 9 April 2018 at 19:17:20 UTC, Adam D. Ruppe wrote:

My understanding is .eml is the same MIME format the email 
itself and mbox and maildir all use.


Thanks. I didn't know that. I will try it using email.d.


Re: Parse .eml files

2018-04-09 Thread Adam D. Ruppe via Digitalmars-d-learn

On Monday, 9 April 2018 at 18:47:16 UTC, bachmeier wrote:
Is there a way to do this in D? The email libraries I've found 
don't appear to work with .eml.


My understanding is .eml is the same MIME format the email itself 
and mbox and maildir all use.


So any of those libraries are likely to work with it.

You should open the eml file in Notepad or whatever and see if 
there are more than one message in it. If so, my email.d can 
handle is mbox 
http://dpldocs.info/experimental-docs/arsd.email.processMboxData.html


just `cast(immutable(ubyte)[]) std.file.read` the file to get 
that array.


Otherwise, my email.d would do it as an individual message you 
can construct with this: 
http://dpldocs.info/experimental-docs/arsd.email.IncomingEmailMessage.this.1.html


just std.file.readText and splitLines to get the string[] array.

my email.d is here 
https://github.com/adamdruppe/arsd/blob/master/email.d it depends 
on dom.d htmltotext.d and characterencodings.d


or on dub http://code.dlang.org/packages/arsd-official%3Aemail


Parse .eml files

2018-04-09 Thread bachmeier via Digitalmars-d-learn
I want to save all email messages related to a research project 
into a directory, call a D program to generate an index of all 
messages, and push it to the repo server. That way all coauthors 
have access to all email messages even if they joined a project 
after several years. My client is Thunderbird, which by default 
creates .eml files.


Is there a way to do this in D? The email libraries I've found 
don't appear to work with .eml.