Access VBA to create tickets

Moderator: crythias

Locked
michaelh81
Znuny newbie
Posts: 25
Joined: 08 Jul 2013, 13:38
Znuny Version: 3.2.9

Access VBA to create tickets

Post by michaelh81 »

Hi all,

I'm using OTRS 3.2.9 in a Windows IIS\ SQL Server setup. However, we have a MS Access 2010 application that is now required to send an email and create a ticket in OTRS. I can create the email in Access and I've installed a web service in OTRS, but how do I acutally create a ticket in OTRS and place it in a queue all behind scenes? I have installed a local version of OTRS on my pc and in Access I have the following code behind a button:

Code: Select all

Private Sub Command0_Click()

MyURL = "http://localhost/otrs/index.pl"

         MyEnv = "<?xml version=""1.0"" encoding=""ISO-8859-1""?>"
         MyEnv = MyEnv & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
         MyEnv = MyEnv & "  <soap:Body>"
        
        MyEnv = MyEnv & "   <TicketCreate>"
        MyEnv = MyEnv & "     <UserLogin>username</UserLogin>"
        MyEnv = MyEnv & "     <Password>password</Password>"
        MyEnv = MyEnv & "     <Ticket>"
        MyEnv = MyEnv & "       <Title>Test Message</Title>"
        MyEnv = MyEnv & "       <QueueID>4</QueueID>"                               
        MyEnv = MyEnv & "       <StateID>4</StateID>"                             
        MyEnv = MyEnv & "       <PriorityID>2</PriorityID>"                      
        MyEnv = MyEnv & "       <OwnerID>1</OwnerID>"                             
        MyEnv = MyEnv & "       <CustomerUser>" & 1 & "</CustomerUser>"        
        MyEnv = MyEnv & "     </Ticket>"
        
        MyEnv = MyEnv & "     <Article>"
        MyEnv = MyEnv & "       <ArticleType>email-external</ArticleType>"          'TYPE - set to e-mail external
        MyEnv = MyEnv & "       <SenderType>system</SenderType>"                    'SENDERTYPE - set to system
        MyEnv = MyEnv & "       <From>Support Team</From>"                 'FROM - set
        MyEnv = MyEnv & "       <Subject>" & MySub & "</Subject>"                   'SUBJECT - set
        MyEnv = MyEnv & "       <Body>" & BodyText & "</Body>"                      'MESSAGE BODY - set
        MyEnv = MyEnv & "       <Charset>ISO-8859-15</Charset>"                     'CHARSET - set
        MyEnv = MyEnv & "       <MimeType>text/html</MimeType>"                    'MIMETYPE - set
        MyEnv = MyEnv & "       <HistoryType>EmailCustomer</HistoryType>"           'HISTORY TYPE - set
        MyEnv = MyEnv & "       <HistoryComment>Just a friendly reminder.</HistoryComment>" ' - set
        MyEnv = MyEnv & "       <AutoResponseType>auto reply</AutoResponseType>"    'AUTO REPLY - set
        MyEnv = MyEnv & "       <NoAgentNotify>0</NoAgentNotify>"                   'NOTIFY AGENT - set
        MyEnv = MyEnv & "     </Article>"
      
        MyEnv = MyEnv & "   </TicketCreate>"
        
        MyEnv = MyEnv & "  </soap:Body>"
        MyEnv = MyEnv & "</soap:Envelope>"
        
        With xmlhtp
        .Open "POST", MyURL, False, "username", "password"
        .setRequestHeader "Host", "localhost"
        .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
        .setRequestHeader "soapAction", "#TicketCreate"
        .send MyEnv
    End With
End Sub
However, I keep receiving Run Time error 424 and it highlights:

.Open "POST", MyURL, False, "username", "password"

I'm guessing I need to set POST? I'm not sure I just found this code in the forum.

Regards,

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

Re: Access VBA to create tickets

Post by jojo »

index.pl is the webinterface. Not a webservise.

If you are using a webservice you don't have to create an email in your access aplication.
"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
michaelh81
Znuny newbie
Posts: 25
Joined: 08 Jul 2013, 13:38
Znuny Version: 3.2.9

Re: Access VBA to create tickets

Post by michaelh81 »

Ah ok. What do I need to do then? I'm creating an email in Access and sending it from here, but then need a copy of this to go into a queue in OTRS to generate the Ticket # and have a copy of the email.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Access VBA to create tickets

Post by jojo »

use the webservices of OTRS (SOAP) vi GenericInterface
"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
Locked