PDA

View Full Version : use data (from / subject / body) from selected message to populate link or webform



dr_patso
09-25-2012, 07:30 PM
submit php form / web form / or just customize link (I have requests active on the field)


Hi all, I would really appreciate some help or direction on this. I searched web form on this forum and went 25 pages deep seeing nothing like this.

currently I have this working for me.



Sub ticketsystem()
'Dim PageNumber As Object

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URL = "wwwDOTticketsystemDOTcom/admin/new_ticketDOTphp"
Request = "?name=john&subject=testing&message=testing123123123"

'get web page
IE.Navigate2 URL & Request
Do While IE.readyState <> 4
DoEvents
Loop




End Sub


takes me to website with the request info populated.

I am happy to do this 2 ways, either have the VBA script login and fill out the webform.. or just have the vba script populate the URL with data from the currently selected email/open email...


like in the code above the link should contain this to pre populate the form...

(I do not need it to submit the form, web session must stay open)

URL= wwwDOTticketsystemDOTcom/admin/new_ticketDOTphp
Request = "?name=nameofsender&subject=subjectofemail&message=body%of%email"

Basically: this is stopping me from having to copy & paste ( subject / from / body ) into a basic html/php form 40 times a day, that's 3 copy & pastes and 3 alt tabs (1 monitor) I still would need to categorize it and enter time spent on the web form, so no need to completely automate.

dr_patso
09-25-2012, 07:44 PM
I might add, maybe populating the link with this



Option Explicit

Private Declare Function ShellExecute _
Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hWnd As Long, _
ByVal Operation As String, _
ByVal Filename As String, _
Optional ByVal Parameters As String, _
Optional ByVal Directory As String, _
Optional ByVal WindowStyle As Long = vbMinimizedFocus _
) As Long

Public Sub OpenUrl()

Dim lSuccess As Long
lSuccess = ShellExecute(0, "Open", "wwwdotgoogledotcom")

End Sub


would be better as to not force use of IE...

dr_patso
09-27-2012, 09:50 AM
okay, i pretty much got it... although trying to figure out how to use obj item body to not include html,, it adds weird "HYPERLINK" text and double spaces and standard return.... as the text area I am inputting the HTML email into only supports plain text.. I tried converting to plain text inside VBA, but i don't want to actually convert the emial, it also keeps the double spaces.. freaking outlook.

launches IE, and helpdesk enters basic login, access new ticket page, take sender name , subject, and body and fill in on new ticket screen. the user then finishes off the form.



Sub HelpdeskNewTicket()
Dim helpdeskaddress As String
Dim objMail As Outlook.MailItem
Dim strbody As String
Dim oldmsg As String
Dim senderaddress As String
Dim addresstype As Integer
Dim ie As Object
Dim sResult As String
Dim dtTimer As Date
Dim lAddTime As Long


Set objItem = GetCurrentItem()


' Sender E=mail Address
senderaddress = objItem.SenderEmailAddress

'Searches for @ in the email address to determine if it is an exchange user
addresstype = InStr(senderaddress, "@")

' If the address is an Exchange DN use the Senders Name
If addresstype = 0 Then
senderaddress = objItem.SenderName
End If


Const sOVIDURL As String = "helpdeskDOTcom/admin"
Const lREADYSTATE_COMPLETE As Long = 4

Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate sOVIDURL

dtTimer = Now
lAddTime = TimeValue("00:00:20")

Do Until ie.readystate = lREADYSTATE_COMPLETE And Not ie.busy
DoEvents
If dtTimer + lAddTime > Now Then Exit Do
Loop

ie.document.getElementById("user").Value = "yourusername"
ie.document.getElementById("password").Value = "yourpassword"
ie.document.forms(0).submit

Do Until ie.readystate = lREADYSTATE_COMPLETE And Not ie.busy
DoEvents
If dtTimer + lAddTime > Now Then Exit Do
Loop

ie.navigate "helpdeskDOTcom/admin/new_ticketDOTphp"

Do Until ie.readystate = lREADYSTATE_COMPLETE And Not ie.busy
DoEvents
If dtTimer + lAddTime > Now Then Exit Do
Loop

While ie.busy
DoEvents
Wend

ie.document.getElementById("name").Value = objItem.SenderName
ie.document.getElementById("subject").Value = objItem.Subject
ie.document.getElementById("message").Value = objItem.Body
dtTimer = Now
lAddTime = TimeValue("00:00:20")
Set ie = Nothing ' If you want to close it.


'Dim PageNumber As Object


Set objItem = Nothing
Set objMail = Nothing
End Sub

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = _
objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = _
objApp.ActiveInspector.currentItem
Case Else
End Select
End Function

dr_patso
09-27-2012, 10:43 AM
okay....

anyone know how to make objItem.Body pull the text only out of HTML format emails??.. i want basically a copy&paste, with HTML emails objItem.Body is throwing the HTML code into the websites plain text text area.