Update Issue on receiving Imap
Added by Patrick Richter almost 13 years ago
Hey Guys!
First of all: in case my questions have already been answered somewhere, I honestly apologize, but I've been searching the net and these forums since yesterday and didn't work it out yet.
I'm trying to set up Redmine to manage incoming tickets from another ticket system - for our company-intern organizing of the calls.
So what I'm basically doing:
I'm receiving imap mails via the raketask redmine:email:receive_imap:
sudo rake -f /dir/of/redmine/Rakefile redmine:email:receive_imap RAILS_ENV="production" host=my.imap.server username=foo password=bar project=erp --trace
- this works, it creates a new issue for every new mail in the box in the project erp. so far, so good, excellent documentation!
I know that there are several keywords I can use in the mail to specify project etc., but couldn't find a documentation for this (e.g. project: erp in the message body).
Is this documented anywhere?
The incoming mails are ALL formatted like this:
<Subject> Call Nr. <thecallnumber>: <subject of the call> <Body> A static, always-the-same text like 'hey guys we've updated your call' <attachment> Call_<thecallnumber>.pdf - including every step of the call the other company madeWhat I'd love to accomplish now:
- when a new mail with a so-far unknown call-id comes in, a new ticket should be created (works.)
- write the call number in a custom field of the project "erp" - I think I can do this via regular expressions in the mailhandler, right?
- whenever a new mail with the very same subject comes in, I want ..
> ... to get the attachment replaced
> ... no new issue to be created
> ... some sort of notice that the external call's been updated in the ticket - super-extra-bonus: get the same ticket-id in redmine like the call-nr of the incoming mail (probably impossible, isn't it? we're having like 1k tickets a year and the incoming ones start at #53000, so I'm sure this won't collide)
Is this possible like I'm hoping it is? I'd be glad to get some keywords, hints, documentation on the subject - I can't believe that no one has done something like this before.
Thanks in advance!
patrick.
Replies (2)
RE: Update Issue on receiving Imap
-
Added by Mischa The Evil almost 13 years ago
I'll give my two cents on the things I can:
Patrick Richter wrote:
I know that there are several keywords I can use in the mail to specify project etc., but couldn't find a documentation for this (e.g. project: erp in the message body).
Is this documented anywhere?
Some are documented at RedmineReceivingEmails.
- write the call number in a custom field of the project "erp" - I think I can do this via regular expressions in the mailhandler, right?
You can set a custom field value through the email too using keywords. See e.g. RE: Setting custom fields through Email which also explains the keywords for start- and due-dates.
- super-extra-bonus: get the same ticket-id in redmine like the call-nr of the incoming mail (probably impossible, isn't it?
Indeed. I think the best is to keep the call-nr inside a custom field.
RE: Update Issue on receiving Imap
-
Added by Patrick Richter almost 13 years ago
Thanks for your Reply! The Problem with using keywords inside the body was that the body was always static.
In the meantime, I managed to get a bit of a web developers time who helped me hangle through this. Right now, it works just as I stated above.
What we've done:
- created a new custom field "Call-ID"
- checked the custom_field_id in the database, it had the number 2
- created a new method within the mailhandler to compare the Call-Nr in the subject (simple new regular expression) with the one in our custom field. this isn't very elegant since we have to loop through the data given back by the select * from - if we
select customized_id from custom_values
directly, the rake task crashes. anyway, since we do only have this one handler for incoming mail, its alright.def receive_issue_reply_callid(issue_id, email)
issue_id_temp = Issue.find_by_sql("select * from custom_values where custom_field_id = 2 AND value="+issue_id.to_s+"")
$issue_id_original = false;
issue_id_temp.each do |a|
$issue_id_original = a.customized_id
end
print $issue_id_original
return unless $issue_id_original
thats basically it.