Je souhaiterai écrire un script utilisant l'API d'OTRS permettant d'automatiser l'envoi de mail avec en piéce jointe un PDF.
Selon mes premiers tests, la création du ticket ainsi que l'article fonctionne, par contre je ne parviens par à ajouter ma pièce jointe.
Pouvez-vous m'aider ? Merci.
Code: Select all
my $RPC = Core->new();
my $TicketNumber = $RPC->Dispatch($SOAP_User, $SOAP_Pass, 'TicketObject','TicketCreateNumber');
print "RPC: New Ticketnumber created: ".$TicketNumber."\n";
my $TicketId = $RPC->Dispatch($SOAP_User, $SOAP_Pass, 'TicketObject', 'TicketCreate',
TN => $TicketNumber,
Title => 'Test Ticket',
QueueID => 8, # or QueueID => 123,
Lock => 'unlock',
PriorityID => 2, # or PriorityID => 2,
State => 'open', # or StateID => 5,
CustomerUser => 'customer at example.com',
OwnerID => 1, # new owner
ResponsibleID => 1, # new responsible
UserID => 1,
);
$myFile = "rapport.pdf";
$contenttype = "text/plain";
$mydir= "/home/benjamin/";
$mydirFile = $mydir . $myFile;
print "RPC: New Ticket id is: $TicketId\n";
my $ArticleID =$RPC->Dispatch($SOAP_User, $SOAP_Pass, 'TicketObject', 'ArticleCreate',
TicketID => $TicketId,
ArticleType => 'email-external', # email-external|email-internal|phone|fax|...
SenderType => 'system', # agent|system|customer
From => 'root <root@localhost>', # not required but useful
To => 'Some Customer A', # not required but useful
Cc => '', # not required but useful
ReplyTo => '', # not required
Subject => 'TEST Ticket 2', # required
Body => "Test Body", # required
#MessageID => '', # not required but useful
Charset => 'iso-8859-15',
HistoryType => 'EmailCustomer', # EmailCustomer|Move|AddNote|PriorityUpdate|WebRequestCustomer|...
HistoryComment => 'Some free text!',
UserID => 1,
NoAgentNotify => 0, # if you don't want to send agent notifications
MimeType => 'text/plain',
Loop => 0, # auto reject|auto follow up|auto follow up|auto remove
Attachment , array(
array('Content' => $theData,'ContentType' => $contenttype,'Filename' => $myFile)
),
);
print "RPC: Article ID created: ".$ArticleID."\n";