Create Article and Send Email

English! place to talk about development, programming and coding
Post Reply
leonidas
Znuny newbie
Posts: 4
Joined: 09 Nov 2012, 15:50
Znuny Version: 3.1.6

Create Article and Send Email

Post by leonidas »

Hello,
im using the php soapclient to create articles in otrs and it works fine.
But i just can create them without send an email to the destination. Also i cant create HTML body for the created article.

Code: Select all

$ticketID = $this->doSOAPCall('Ticket','TicketCreate',array(
            'UserID'        => $this->OTRS_user_id,
            'QueueID'       => $CONFIG['queueIDs']['export'],
            'Lock'          => 'unlock',
            'Title'         => $subject,
            'Priority'      => '3 normal',
            'State'         => 'new',
            'CustomerID'    => 'test@test.com',
            'CustomerUser'  => 'test@test.com',
            'OwnerID'       => 1
        ));
 
        $articleID = $this->doSOAPCall('Ticket','ArticleCreate',array(
            'UserID'        => $this->OTRS_user_id,
            'TicketID'      => $ticketID,
            'To'            => 'dest@mail.com',
            'From'          => 'from@mail.com',
            'ArticleType'   => 'email-external',
            'SenderType'    => 'system',
            'Subject'       => "topic",
            'Body'          => "<b>hello world</b>",
            'ContentType'   => 'text/html; charset=UTF-8',
            'HistoryType'   => 'OwnerUpdate',
            'HistoryComment'=> '--'
        ));
First of all i got to say that my soap-request logic works and thats not the problem. The ticket was created with the article, but - as i told - the html doesnt work and the email has not been sent. I tried the ArticleSend - method, but it didnt work, too. Because of lack of error reporting i cant tell you why.
I saw something about the ArticlePlain but i dont understand it at all.

Hope you can help me!
Thanks
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Create Article and Send Email

Post by reneeb »

Try to use ArticleSend instead of ArticleCreate and pass some extra params (see ArticleSend in Kernel::System::Ticket::Article on http://dev.otrs.org/)
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
leonidas
Znuny newbie
Posts: 4
Joined: 09 Nov 2012, 15:50
Znuny Version: 3.1.6

Re: Create Article and Send Email

Post by leonidas »

Well, yesterday i was trying to make ArticleSend work for like 2 hours, no chance. Today i try again after your post and it works! :?
But there is stil a problem, the body of my new article stil just plain text and doesnt show the html elements. Maybe you can see my mistake:

Code: Select all

        $articleID = $this->doSOAPCall('Ticket','ArticleSend',array(
            'UserID'        => $this->OTRS_user_id,
            'TicketID'      => $ticketID,
            'SenderType'    => 'system',
            'ArticleType'   => 'email-external',
            'To'            => 'to@mail.com',
            'From'          => 'from@mail.com',
            'SenderType'    => 'system',
            'Subject'       => "topic",
            'Body'          => "<html><head></head><body><b>hello world</b></body></html>",
            'Charset'       => 'utf-8',
            'MimeType'      => 'text/html',
            'HistoryType'   => 'OwnerUpdate',
            'HistoryComment'=> '--',
            'Loop'          => 0
        ));
        __("Artikel ID: ".$articleID);
leonidas
Znuny newbie
Posts: 4
Joined: 09 Nov 2012, 15:50
Znuny Version: 3.1.6

Re: Create Article and Send Email

Post by leonidas »

Sorry for doublepost, but want to push my Thread a bit and update my Problem:

Now i can send emails thru the rpc API, but stil have this annoying 'bug', which i cant solve by myself. The Subject of the Email isn't uft8 encoded, i cant display special chars properly.
And still i cant display HTML in the article and the email. The API inserts the body-text in the article_attachment table and converts all the < and > to HTML-Code.
Somebody can help me pls!?

greetz
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Create Article and Send Email

Post by jojo »

sending an HTML email would need to upload an HTML attachment. The body always is plaintext. Both together are sent as a multipart/MIME message
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
leonidas
Znuny newbie
Posts: 4
Joined: 09 Nov 2012, 15:50
Znuny Version: 3.1.6

Re: Create Article and Send Email

Post by leonidas »

Ok, i tried to attach the html as a file but it just was attached to the email and now displayed in the body. My initial html-code was automatically attached to the email with replacing < and >. How to i exactly attach the html code and display it, would be pleased to receive a hint!

PS: Problem with that is that the body of the article in the OTRS is displayed as code and not as html. Not only in the mail...
Post Reply