Jump to content

thisca

Members
  • Posts

    3
  • Joined

  • Last visited

thisca's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. I am trying to get emails from outlook into AutoIt and need help getting the email header property. This is the script that I am using (it works for the fields listed): #include <array.au3> #include <OutlookEX.au3> $oOutlook = _OL_Open() $aItems = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, '[Subject]="Test"', "", "", "Subject,Body,To,SenderEmailAddress,EntryID,CreationTime,SentOn,SenderName", "", 1) If IsArray($aItems) Then _ArrayDisplay($aItems, @ScriptLineNumber) EndIf My problem is that the email header is not a standard property that I can include in the properties list. From internet search, it appears that the header information from Outlook emails is available with: PropertyAccessor.GetProperty, and the property is: PR_MAIL_HEADER_TAG. I do not know how to format this to include it in the _OL_ItemFind function call or how to modify the _OL_ItemFind function to return this information. Any suggestions? Thanks
  2. I am trying to get a list of available papersize names and the papersize numbers for all of the printers installed on the computer. This is what I have so far: #include <Array.au3> Const $DC_PAPERNAMES = 16 Const $DC_PAPERS = 2 Const $DC_PAPERSIZE = 3 Dim $BinNameList, $struct $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colInstalledPrinters = $objWMIService.ExecQuery("Select Name, PortName from Win32_Printer") For $objPrinter In $colInstalledPrinters $Printer_Name = $objPrinter.Name $Printer_Port = $objPrinter.PortName $result = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $Printer_Name, "str", $Printer_Port, "int", $DC_PAPERNAMES, "str", DllStructGetPtr($struct), "long", 0) _ArrayDisplay($result) Next This AutoIt script will step through each print driver installed and show the number of page sizes available for that printer, printer name, and the first page size. What I am not able to do is loop through the rest of the page sizes for each printer and also get the pagesize numbers for each printer. This VB code will do what I want but I am having trouble formatting the DLL calls to make it work in AutoIt: Option Explicit Private Declare Function DeviceCapabilities Lib _ "winspool.drv" Alias "DeviceCapabilitiesA" _ (ByVal lpsDeviceName As String, ByVal lpPort _ As String, ByVal iIndex As Long, lpOutput As Any, _ ByVal dev As Long) As Long Private Type POINTAPI x As Long y As Long End Type Private Const DC_PAPERNAMES = 16 Private Const DC_PAPERS = 2 Private Const DC_PAPERSIZE = 3 Private Sub Command1_Click() Dim lPaperCount As Long, lCounter As Long Dim hprinter As Long, sDeviceName As String Dim sDevicePort As String, sPaperNamesList As String Dim sNextString As String, numPaper() As Long Dim paperNumbers() As Integer, paperSizes() As POINTAPI List1.Clear lPaperCount = DeviceCapabilities(Printer.DeviceName, _ Printer.Port, DC_PAPERNAMES, ByVal vbNullString, 0) ReDim numPaper(1 To lPaperCount) sPaperNamesList = String(64 * lPaperCount, 0) ' Get paper names lPaperCount = DeviceCapabilities(Printer.DeviceName, _ Printer.Port, DC_PAPERNAMES, ByVal sPaperNamesList, 0) ' Get matching paper numbers ReDim paperNumbers(1 To lPaperCount) lPaperCount = DeviceCapabilities(Printer.DeviceName, _ Printer.Port, DC_PAPERS, paperNumbers(1), 0) ReDim paperSizes(1 To lPaperCount) lPaperCount = DeviceCapabilities(Printer.DeviceName, _ Printer.Port, DC_PAPERSIZE, paperSizes(1), 0) For lCounter = 1 To lPaperCount sNextString = Mid(sPaperNamesList, _ 64 * (lCounter - 1) + 1, 64) sNextString = Left(sNextString, _ InStr(1, sNextString, Chr(0)) - 1) List1.AddItem paperNumbers(lCounter) & vbTab & vbTab _ & Format(paperSizes(lCounter).x / 254, "0.00") & " x " _ & Format(paperSizes(lCounter).y / 254, "0.00") _ & " inch" & vbTab & vbTab & sNextString Next lCounter End Sub Any help would be appreciated.
  3. I am trying to filter appointments by LastModificationTime I have modified the _OutlookGetAppointments function adding an additional parameter: $LastModificationTime and adding script steps that add $LastModificationTime into $sFilter (see code). I have also added LastModificationTime to the return results. Last modification time returns in this format: 20091125101920, however I have tried filtering appointments by this and other date / time formats and I do not even get the popup dialog from Outlook that a program is trying to access Outlook. So I assume that I am causing some error. What am I doing wrong? Thanks Func _OutlookGetAppointments($oOutlook, $sSubject = "", $sStartDate = "", $sEndDate = "", $sLocation = "", $iAllDayEvent = 2, $iImportance = "", $LastModificationTime="") Local $avAppointments[1000][10], $sFilter = "", $fAllDayEvent, $oFilteredItems Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") Switch $iAllDayEvent Case 0 $fAllDayEvent = False Case 1 $fAllDayEvent = True EndSwitch $avAppointments[0][0] = 0 Local $oNamespace = $oOutlook.GetNamespace("MAPI") Local $oFolder = $oNamespace.GetDefaultFolder($olFolderCalendar) Local $oColItems = $oFolder.Items $oColItems.Sort("[Start]") $oColItems.IncludeRecurrences = True If $sSubject <> "" Then $sFilter = '[Subject] = "' & $sSubject & '"' EndIf If $sStartDate <> "" Then If Not _DateIsValid($sStartDate) Then Return SetError(1, 0, 0) If $sFilter <> "" Then $sFilter &= ' And ' $sFilter &= '[Start] >= "' & $sStartDate & '"' EndIf If $sEndDate <> "" Then If Not _DateIsValid($sEndDate) Then Return SetError(1, 0, 0) If $sFilter <> "" Then $sFilter &= ' And ' $sFilter &= '[End] <= "' & $sEndDate & '"' EndIf If $sLocation <> "" Then If $sFilter <> "" Then $sFilter &= ' And ' $sFilter &= '[Location] = "' & $sLocation & '"' EndIf If $iImportance <> "" Then If $sFilter <> "" Then $sFilter &= ' And ' $sFilter &= '[Importance] = "' & $iImportance & '"' EndIf If $LastModificationTime <> "" Then If $sFilter <> "" Then $sFilter &= ' And ' $sFilter &= '[LastModificationTime] > "' & $LastModificationTime & '"' EndIf $oFilteredItems = $oColItems.Restrict($sFilter) ;MsgBox (0,'Filter',$sFilter) If $sFilter = "" Then Return SetError(1, 0, 0) For $oItem In $oFilteredItems $oItem.IsRecurring If $avAppointments[0][0] = 999 Then SetError (3) Return $avAppointments EndIf If $iAllDayEvent <> 2 Then If $fAllDayEvent = True Then If $oItem.AllDayEvent = False Then ContinueLoop Else If $oItem.AllDayEvent = True Then ContinueLoop EndIf EndIf $avAppointments[0][0] += 1 $avAppointments[$avAppointments[0][0]][0] = $oItem.Subject $avAppointments[$avAppointments[0][0]][1] = $oItem.Start $avAppointments[$avAppointments[0][0]][2] = $oItem.End $avAppointments[$avAppointments[0][0]][3] = $oItem.Location $avAppointments[$avAppointments[0][0]][4] = $oItem.AllDayEvent $avAppointments[$avAppointments[0][0]][5] = $oItem.Importance $avAppointments[$avAppointments[0][0]][6] = $oItem.Body $avAppointments[$avAppointments[0][0]][7] = $oItem.Categories $avAppointments[$avAppointments[0][0]][8] = $oItem.GlobalAppointmentID $avAppointments[$avAppointments[0][0]][9] = $oItem.LastModificationTime Next $oItem = "" $oColItems = "" $oFolder = "" $oNamespace = "" If $avAppointments[0][0] = 0 Then Return SetError(2, 0, 0) Redim $avAppointments[$avAppointments[0][0] + 1][10] Return $avAppointments EndFunc
×
×
  • Create New...