我想为outlook创建一个宏。
我需要提取选定的电子邮件主题,在线和正文,并在网站上预填充3个文本字段。
我已经可以通过网址(website / form.php?name = xxx& subject = xxx& message = xxxx)
无论
宏从所选消息中提取3个字段,并构建预先填充的链接以将用户发送到。
宏登录到该网站并填写表格中的数据。
答案 0 :(得分:0)
我找到了!
http://developers.phpjunkyard.com/viewtopic.php?f=13&t=4241
你会在那里找到我的代码。
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 = "http://helpdesk.com/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 "http://helpdesk.com/admin/new_ticket.php"
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