#1
|
|||
|
|||
Is there an alternative to "GetDefaultFolder"
Hello - first time posting in this forum (I have an MS Access account same name etc)
I have raised this in the access forum - but its is more an Outlook rather than Access question I have a little bit of coding (I have edited tot he problem element) basically it looks int he sent items - sees the email that has been referenenced and copies /renames it into a network folder - works a dream - until ..... If I have two Outlook accounts (I do - ) it only checks the "default" sent items and never the alternative one - even though i send from the alternaive Effectively what i am looking for is an alternative to getdefaultfolder (sent) to get sent folder from either account no 1 or account no 2 (or check all "sent" folders code below not bothered if it checks both sent folders - but i am stuck on this - coding is not mine - #i have hacked it to suit purpose ( With olkns.GetDefaultFolder(olFolderSentMail)) Private Function FindSentItem(itemID As String, sentFromTime As Date) As Outlook.MailItem Const MAX_TRY_COUNT = 3 Const SLEEP_TIME = 1000 Dim olkapp As Outlook.Application Dim olkns As Outlook.NameSpace Dim olAcc As Outlook.Account Dim items As Outlook.items Dim item As Object Dim attempt As Integer Set olkapp = Outlook.Application '### 'Set olAcc = Outlook.Accounts.Session(2) Set olkns = olkapp.GetNamespace("MAPI") attempt = 1 findSentItem_start: With olkns.GetDefaultFolder(olFolderSentMail) Set items = .items.Restrict("[SentOn] >= '" & Format(sentFromTime, "ddddd h:nn AMPM") & "'") For Each item In items If TypeName(item) = "MailItem" Then If item.Categories = itemID Then Set FindSentItem = item Exit Function End If End If Next item End With ' ' If not found at this attempt, try again ' after some sleep ' If attempt < MAX_TRY_COUNT Then attempt = attempt + 1 ' Pause (0.1)is 0.1 second Pause (3) 'Call Sleep(SLEEP_TIME) GoTo findSentItem_start End If Set FindSentItem = Nothing End Function Private Sub Command188_Click() 'DoCmd.SetWarnings False DoCmd.OpenQuery "QuoteemptyemailtxtQry", acViewNormal, acEdit Me.RecZlocked = -1 'DoCmd.SetWarnings True DoCmd.RunCommand acCmdSaveRecord DoCmd.Close 'QuoteemptyemailtxtQry End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
"Magic" indentation for "too-long" text-lines that are longer than one line | pGrnd | Word | 2 | 04-20-2020 03:23 PM |
Combine "sort within groups" and "identify duplicate/unique values" in two different variables. | civilcervant | Excel | 3 | 06-12-2017 07:27 AM |
Error: "Changes made were lost...reconnect with server", when switching "from" field | randhurrle | Outlook | 2 | 02-25-2015 06:51 PM |
remove repeated words with " macro " or " wild cards " in texts with parentheses and commas | jocke321 | Word VBA | 2 | 12-10-2014 11:27 AM |
How to choose a "List" for certain "Heading" from "Modify" tool? | Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |