[quote user="Rolf Lindby"]
I mainly write in Pascal and haven't made any global daemon that modifies raw message data, but I did a small test which worked OK in my system (slightly simplified code with just the main ingredients):
if mi.ji_access_job_data(job, Filename, 256) = 1 then
begin
mi.logstring(10, LOG_DEBUG, 'Message extracted');
if mi.edit_message_headers(Filename, AddHeaders, DelHeaders) = 1 then
mi.logstring(10, LOG_DEBUG, 'Headers have been modified.')
else mi.logstring(10, LOG_DEBUG, 'Error modifying headers.');
mi.ji_unaccess_job_data(job);
end
else
mi.logstring(10, LOG_DEBUG, 'Failed to extract message');
Result := 0;[/quote]
That's basically the same as the one I had posted except that I did no logging and did call ji_open/close_job. So I mimmicked yours (C code below). It worked! I don't know what the problem was with using ji_open/close_job. Thanks.
CHAR *rid[2] = {"Sender", NULL};
CHAR filename[MAX_PATH];
if ( mi->ji_access_job_data(job, filename, MAX_PATH) )
{
mi->logstring(10, LOG_DEBUG, filename);
if ( mi->edit_message_headers(filename, &rid[1], rid) )
mi->logstring(10, LOG_DEBUG, "Headers modified");
else
mi->logstring(10, LOG_DEBUG, "Error modifying headers");
mi->ji_unaccess_job_data(job);
}
else
mi->logstring(10, LOG_DEBUG, "Failed to access job data");
return 0;
P.S., In the forum's message composer, how do you get your code to appear in a box?
[quote user="Rolf Lindby"]<p>I mainly write in Pascal and haven't made any global daemon that modifies raw message data, but I did a small test which worked OK in my system (slightly simplified code with just the main ingredients):</p>
<blockquote>
&nbsp; <i>&nbsp;if mi.ji_access_job_data(job, Filename, 256) = 1 then</i>
<i>&nbsp; begin</i>
<i>&nbsp; &nbsp;mi.logstring(10, LOG_DEBUG, 'Message extracted');</i>
<i>&nbsp; &nbsp; if mi.edit_message_headers(Filename, AddHeaders, DelHeaders) = 1 then</i>
<i>&nbsp; &nbsp; &nbsp; mi.logstring(10, LOG_DEBUG, 'Headers have been modified.')</i>
<i>&nbsp; &nbsp; else mi.logstring(10, LOG_DEBUG, 'Error modifying headers.');</i>
<i>&nbsp; &nbsp; mi.ji_unaccess_job_data(job);</i>
<i>&nbsp; end</i>
<i>else </i>
<i>&nbsp; &nbsp;mi.logstring(10, LOG_DEBUG, 'Failed to extract message');&nbsp;</i>
<i>&nbsp; Result := 0;</i>[/quote]
</blockquote>&nbsp;That's basically the same as the one I had posted except that I did no logging and did call ji_open/close_job.&nbsp; So I mimmicked yours (C code below).&nbsp; It worked!&nbsp; I don't know what the problem was with using ji_open/close_job.&nbsp; Thanks.<blockquote>&nbsp;&nbsp;&nbsp; CHAR *rid[2] = {"Sender", NULL};
&nbsp;&nbsp;&nbsp; CHAR filename[MAX_PATH];
&nbsp;&nbsp;&nbsp; if ( mi-&gt;ji_access_job_data(job, filename, MAX_PATH) )
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mi-&gt;logstring(10, LOG_DEBUG, filename);
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( mi-&gt;edit_message_headers(filename, &amp;rid[1], rid) )
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mi-&gt;logstring(10, LOG_DEBUG, "Headers modified");
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mi-&gt;logstring(10, LOG_DEBUG, "Error modifying headers");
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mi-&gt;ji_unaccess_job_data(job);
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mi-&gt;logstring(10, LOG_DEBUG, "Failed to access job data");
&nbsp;&nbsp;&nbsp; return 0;
</blockquote>P.S., In the forum's message composer, how do you get your code to appear in a box?