 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
BoBoł Guest
|
Posted: Mon Feb 02, 2009 9:05 am Post subject: Outlook Redemption - Access Outlook using Data Objects [COM] |
|
|
| Quote: | What is Outlook Redemption?
Outlook Redemption works around limitations imposed by the Outlook Security Patch and Service Pack 2 of MS Office 98/2000 and Office 2002/2003/2007 (which include Security Patch) plus provides a number of objects and functions to work with properties and functionality not exposed through the Outlook object model.
As of version 4.0, Redemption library also includes the RDO (Redemption Data Objects) family of objects that can function as a CDO 1.21 replacement.
With Outlook Redemption you can
Make your code run unaffected by the Security Patch.
Access properties not exposed by the Outlook Object Model (internet message headers, sender e-mail address and hundreds more properties)
Display Address Book.
Directly access RTF body of any Outlook item
Import MSG, EML (RFC822) and TNEF files
Export messages to the MSG, EML, TXT, HTML, TNEF and vCard formats.
Access and manipulate Outlook accounts (Outlook 2002 and above, RDO library)
Create, access and manipulate MAPI profiles and accounts (Profman library)
Access MAPI stores (not exposed in the Outlook Object Model at all)
Directly access message attachments as strings or as arrays without saving them as files first
And much, much more!
Redemption supports Outlook 98, 2000, 2002, 2003 and 2007 (Outlook 97 is not supported by the Safe*Item objects). The RDO family of objects can also be used with the Exchange Server versions of MAPI.
Using Outlook Redemption
Please follow and carefully read the links below before using Outlook Redemption.
Redemption objects providing access to the properties, functions and objects blocked by the Outlook Security Patch. In addition to providing the exact replica of the corresponding Outlook objects, some of these objects have extra properties and methods, such as RTFBody on all Safe*Item objects, AsString and AsArray on attachments, etc. These objects are designed to be used alongside your existing OOM or CDO 1.21 code with as few modifications as possible.
RDO (Redemption Data Objects) library is designed to be used as a complete CDO 1.21 replacement. This family of objects is designed to be used standalone, but it can of course still be used along with your existing OOM or CDO code.
Miscellaneous Redemption objects providing access to the Extended MAPI properties and functionality not available through the Outlook Object Model.
How Outlook Redemption works
Redemption is a regular COM library; once registered on the system, it is accessible to any programming language (VB, VBA, VC++, Delphi, etc). Redemption uses Extended MAPI (which is not affected by the Security Patch since it is not accessible to the scripting languages) to duplicate the functionality blocked by the Security Patch. All Safe*Item Redemption objects have an Item property which must be set to an Outlook item. Once set, you can access any properties and methods, both blocked and not blocked. For the blocked properties and functions, Redemption objects completely bypass the Outlook object model and behave exactly like Outlook objects with no Security Patch applied. For the properties and methods not blocked by the Security Patch, all calls are transparently forwarded to the Outlook object that you assign to the Item property. With this approach changes to your code are minimal: you only change the way you declare the objects, but not the rest of your code that actually accesses both blocked and not blocked properties and methods.
[Home] | If someone out there would provide some AHK Code to parse incomming mails this way, he/she would be nominated for the AHK-Hall of Fame. Promised!  |
|
| Back to top |
|
 |
cdjones
Joined: 15 Sep 2009 Posts: 67 Location: Ga, USA
|
Posted: Tue Oct 06, 2009 10:06 pm Post subject: |
|
|
try :
| Code: |
For Each item In SubFolder.Items
'create a safe item
Set sitem = CreateObject("Redemption.SafeMailItem")
sitem.item = item
For Each Atmt In sitem.Attachments
FileName = StrSourceFolder & "\" & Atmt.FileName
Atmt.SaveAsFile FileName
Next Atmt |
|
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Wed Oct 07, 2009 3:36 am Post subject: |
|
|
I've known about this error for a long time, but have never seen a very convenient work-around. Perhaps that Outlook Redemption may do the trick.
Here is another site I just found that really gets into the nitty-gritty of all the different work-arounds.
http://www.outlookcode.com/article.aspx?ID=52
While I may be familiar with COM, I can't say I'm much of an Outlook API pro.
-not quite god ;) |
|
| Back to top |
|
 |
cdjones
Joined: 15 Sep 2009 Posts: 67 Location: Ga, USA
|
Posted: Wed Oct 07, 2009 12:31 pm Post subject: |
|
|
I did get this working with Redemption
| Code: | #include ws4ahk.ahk
VBScript =
(
dim wsh, sitem, itm
Set objoutlook = CreateObject("Outlook.Application")
Set nms = objoutlook.GetNamespace("MAPI")
Set fld = nms.GetDefaultFolder(10)
'Test whether selected folder contains contact items
If fld.DefaultItemType <> 2 Then
MsgBox "Folder does not contain contacts"
End If
lngCount = fld.Items.Count
If lngCount = 0 Then
MsgBox "No Contacts to export"
Else
' msgbox lngCount & " Contacts to export"
End If
set wsh = createobject("WScript.Shell")
profile = wsh.ExpandEnvironmentStrings("`%UserProfile`%")
myf = profile & "\My Documents\My Scripts\outlookcontacts.txt"
msgbox myf
Set fs = CreateObject("Scripting.FileSystemObject")
if(fs.fileexists(myf)) then
msgbox "deleting"
Set a = fs.GetFile(myf)
a.Delete
else
end if
Set outfile = fs.OpenTextFile(myf, 2, True)
For Each itm In fld.Items
Set sitem = CreateObject("Redemption.SafeContactItem")
sitem.item = itm
outstr = ""
If sitem.Class = 40 Then
If (sitem.Email1Address <> "" And InStr(sitem.Email1Address, "@") > 0) Then
j = j + 1
If sitem.FirstName <> "" Then
outstr = j & "|" & Trim(sitem.FirstName)
Else
outstr = j & "|"
End If
If sitem.LastName <> "" Then
If sitem.FirstName = "" Then
outstr = outstr & Trim(sitem.LastName) & "|aexxx"
Else
outstr = outstr & " " & Trim(sitem.LastName) & "|aexxx"
End If
End If
If sitem.BusinessTelephoneNumber <> "" Then
busno = canonical(sitem.BusinessTelephoneNumber)
outstr = outstr & "|bp" & busno
Else
outstr = outstr & "|bpxxx"
End If
If sitem.MobileTelephoneNumber <> "" Then
mobno = canonical(sitem.MobileTelephoneNumber)
outstr = outstr & "|cm" & mobno
Else
outstr = outstr & "|cmxxx"
End If
If sitem.Email1Address <> "" Then outstr = outstr & "|" & sitem.Email1Address
outstr = outstr & "|" & sitem.Email1DisplayName
outfile.writeline(LCase(outstr))
End If
i = i + 1
End If
Next
outfile.close
Function canonical(s)
strDial = Trim(s)
For i = 1 To Len(strDial)
n = Mid(strDial, i, 1)
If isnumeric(n) Then p = p & n
Next
if (len(p)=10) then res = mid(p,1,3) & "-" & mid(p,4,3) & "-" & right(p,4)
if( len(p)>10) then res=left(p,len(p)-10) & "-" & res
if (len(p)<10) then
for i=len(p) to 1 step -1
res=mid(p,i,1) & res
if (i=4 and len(p)>4) then res="-" & res
if (i=7 and len(p)>7) then res="-" & res
next
end if
canonical=res
End Function
msgbox "Contacts Exported"
)
WS_Initialize()
msgbox init
WS_Exec(VBScript)
If errorlevel != 0
msgbox % errorlevel
WS_Uninitialize() |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|