outlook-vba

Outlook.Exe Keeping Handle After Attachment Save VB

瘦欲@ 提交于 2019-12-11 11:23:09
问题 I have some VBA that i use to download all the attachments from an email and save them to a directory. This is causing me some problems because the handle from Outlook is remaining on the folder and as a result it fails to delete correctly. I thought my code is pretty fool proof and shouldn't be keeping a hold on the folder after the completion of the script. Can someone please point out to me what I have done wrong :/ Sub SaveCustDetails(myItem As Outlook.MailItem) 'On Error Resume Next Dim

VBA Outlook 2010 retrieving information from Active Directory

拈花ヽ惹草 提交于 2019-12-11 11:20:07
问题 I’m using VBA in Outlook 2010 and I’m trying to create a function that will retrieve a selected user Home folder path from Active Directory. The following code is a simple pop up that has the saving destination. Sub SaveSelected() 'Declaration Dim myItems, myItem, myAttachments, myAttachment Dim myOrt As String Dim myOLApp As New Outlook.Application Dim myOlExp As Outlook.Explorer Dim myOlSel As Outlook.Selection Dim objFSO As Object Dim intCount As Integer 'Ask for destination folder myOrt =

How to set reference to shared inbox folder?

 ̄綄美尐妖づ 提交于 2019-12-11 11:06:43
问题 I found this code in another search, but when I run it, I get "No Such Folder" error. I would like to count emails in a shared inbox folder. Can anyone advise on how to change this code to accomplish this? Sub HowManyEmails() Dim objOutlook As Object, objnSpace As Object, objFolder As MAPIFolder Dim EmailCount As Integer Set objOutlook = CreateObject("Outlook.Application") Set objnSpace = objOutlook.GetNamespace("MAPI") On Error Resume Next Set objFolder = objnSpace.Folders("Personal Folders"

Outlook VBA macro not recognized

廉价感情. 提交于 2019-12-11 10:59:42
问题 I'm having difficulty getting Outlook 2010 VBA to recognize a macro that I copied directly from the web. The macro is supposed to extract a copy of an attachment from an e-mail message and save it to a local folder. It worked several days ago, but now, when I try to run the code in VBA with (itm as Outlook.MailItem), Outlook doesn't recognize it as any kind of macro. When I take that out and leave just parentheses, it shows as a macro, but I get a 424 object required error and can't run the

Compare text from the subject line against current date - 1

别等时光非礼了梦想. 提交于 2019-12-11 10:44:28
问题 I've a list of mails that come in every few days with the subject as: CUSTOMER ORDERS1-04/11/2015 CUSTOMER ORDERS2-04/11/2015 CUSTOMER ORDERS3-04/11/2015 CUSTOMER ORDERS1-03/11/2015 CUSTOMER ORDERS2-03/11/2015 CUSTOMER ORDERS3-03/11/2015 I want to do something only when subject is CUSTOMER ORDERS1 and 04/11/2015 = todays date - 1. I'm thinking I would need to extract textual date from the subject, then convert it to date format as DD/MM/YYYY Then compare that date against the current -1 in

How do I write an IF statement that searches for a specific word in an email's subject line

只谈情不闲聊 提交于 2019-12-11 10:26:29
问题 I've got a rule + script setup in outlook. The rule looks for specific words in the email subject and then runs the script (defined in Modules) below. But it seems to be only working for my personal inbox and not a group inbox. The below is the code that works. The lines in comments are me trying to work it out. Public Sub saveAttachtoDisk(item As Outlook.MailItem) Dim objAtt As Outlook.Attachment Dim saveFolder As String saveFolder = "d:\temp\" Dim objNS As Outlook.NameSpace Set Items =

VBA Using Outlook to open excel not opening

烂漫一生 提交于 2019-12-11 10:10:10
问题 Hi Thanks for your help. I have the follow code in Outlook 2010 & 2007: Sub Openexcel() Dim xlApp As Object Dim sourceWB As Workbook Dim sourceSH As Worksheet Dim strFile As String Set xlApp = CreateObject("Excel.Application") With xlApp .Visible = True .EnableEvents = False End With strFile = "E:\All documents\susan\work\Excel projects\saving files to directory Clean.xls" Set sourceWB = Workbooks.Open(strFile, , False, , , , , , , True) Set sourceSH = sourceWB.Worksheets("Sheet2") sourceWB

How to use “Always Move Messages in This Conversation” feature from VBA in MS Outlook?

百般思念 提交于 2019-12-11 09:53:59
问题 I'm trying to implement a search and move feature in MS Outlook. Search is OK, it works like charm. But, I can find only the Move function to move message into an Outlook folder. I use the Always Move Messages in This Conversation feature manually. Now, I'd like to use it from macro. Is there any way to use this feature from VBA? Here is the current implementation but it uses the simple Move feature: Private Sub btn_Click() Dim currentMail As Object Dim F As Outlook.MAPIFolder Dim Msg$ Set

Search for a string in a subject

旧城冷巷雨未停 提交于 2019-12-11 09:40:04
问题 I am using VBA in MSOutlook to search for a string in the subject line and if it is present then prompt a warning. Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim strSubject As String strSubject = Item.Subject If strSubject.Contains("ZAFTM") or Else strSubject.Contains ("BENSP") Then Prompt$ = "operator, Can I send the mail?" If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo Then Cancel = True End If End If End Sub This

Outlook Task Scheduler to Run Access Subs

☆樱花仙子☆ 提交于 2019-12-11 09:35:21
问题 I have Access Macros that run a series of queries, form a tables, and send those tables to multiple recipients. This works fine, but I'm being increasingly asked to supply an increasing number of reports on a set day of the week. Rather than use my calendar to remind me to open Access and run these Macros, can I run VBA in Outlook to run an Access macro on a certain day? 回答1: Rather than use my calendar to remind me to open Access and run these Macros, can I run VBA in Outlook to run an