[rt-users] Sending Mail With Attachments
Otmar Lendl
lendl at nic.at
Thu Dec 16 07:28:21 EST 2004
On 2004/12/15 22:12, Stephen Turner <sturner at MIT.EDU> wrote:
> Quoting Otmar Lendl <lendl at nic.at>:
>
> > On 2004/12/15 15:12, Stephen Turner <sturner at MIT.EDU> wrote:
> > >
> > > Hi,
> > >
> > > I'm trying to set up a scrip that will send mail with a piece of text
> > stored as
> > > an attachment, and I'm not getting anywhere. Could anyone give me a hint?
> > >
> >
> > I'm using a scrip with the default "Notify Requestors" Action combined
> > with a Template whose Content starts with
> >
> > RT-Attach-Message: yes
> > Subject: ....
> >
>
> I guess I need more than a hint :)
>
> What I'm trying to do is to have the queue-change action send mail to the
> requestor - the mail needs to have some text (from a ticket CF) included as an
> attachment.
Hehe, I had so solve something similar. It's just XML in my case.
> Just adding "RT-Attach-Message: yes" at the top of the template doesn't work for
> me - the queue-change transaction has no attachments, so no attachments are
> added to the mail message (per Send_Email.pm).
In my case, a different scrip is creating the attachment. Code-snippet:
$entity = MIME::Entity->build(
Subject => "Billing Record",
Type => "text/xml",
Encoding => "utf8",
Data => $br,
Description => "Billing Record",
Disposition => "attachment",
Filename => "billing.xml",
);
$self->TransactionObj->_Attach( $entity );
[I'm not sure whether this is indeed the proper way of doing this.]
> I forced my template to create an attachment for the transaction to work around
> the above problem, put this also didn't work because the Mime type is
> plain/text and there's code in Send_Email.pm to prevent the attachment for this
> mime type (I don't know why).
The relevant code is: (on my 3.0.11 installation)
# We want to make sure that we don't include the attachment that's being sued as the "Content" of this message"
next
if ( $transaction_content_obj
&& $transaction_content_obj->Id == $attach->Id
&& $transaction_content_obj->ContentType =~ qr{text/plain}i
);
hmm.
digging around in the code leads me to the conclusion that in your
case the transaction doesn't have its own Content object (e.g. there is
no comment when you close the ticket), and thus your attachment
is considered to be the comment (and thus unsuitable for attaching).
> To solve that I created an attachment of type text/html - this finally had the
> effect of adding an attachment to the mail message. But I'm left feeling that
> it's an ugly solution and there must be a more elegant way. Plus I would really
> like to send a text/plain attachment and am not sure why that is prevented by
> the API.
>
> If anyone can shed any light I'd be very grateful.
I'd recommend adding a dummy text attachment to the ticket before you add
the one you want to have attached.
/ol
--
< Otmar Lendl (lendl at nic.at) | nic.at Systems Engineer >
More information about the rt-users
mailing list