我想为 Outlook 创建一个宏。
我需要提取选定的电子邮件主题、发件人行和正文,并使用该数据预先填充网站上的 3 个文本字段。
我已经可以通过 URL (website/form.php?name=xxx&subject=xxx&message=xxxx) 做到这一点
任何一个
宏从选定的消息中提取 3 个字段并构建预填充的链接以将用户发送到。
宏登录到所述站点并填写表格上的数据。
我找到了!
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