outlook-vba

Items.Restrict appointments in Outlook Calendar (VBA)

心不动则不痛 提交于 2020-01-06 08:31:54
问题 I'm trying to get all appointments in a calendar occurring between the 5th of this month and the 4th of next month (including appointments that happen on those days). Here is the code: Private Sub Application_Startup() Dim oOL As New Outlook.Application Dim oNS As Outlook.NameSpace Dim oAppointments As Object Dim monthlyPats As Object Dim oAppointmentItem As Outlook.AppointmentItem 'Set up date filter Dim sMth As Date Dim eMth As Date sMth = dhFirstDayInMonth() + 3 '4th of this month eMth =

Obtain “sender” and “emailbody” properties

荒凉一梦 提交于 2020-01-06 08:21:08
问题 Background I scan the inbox in Outlook and report the results to a Excel spreadsheet based on the Title of the email. I will use the same example as in Microsoft office keyword and will say "Office". IE: Office: Problem with Laptop. I need to get the user name or email address that sent the mail and probably some keywords in the body of the email itself. I found the way to iterate through the items that have this keyword only by using tables and rows. Problem I have not been able to find a

Count Emails In Inbox Every Hour And Save To text file

醉酒当歌 提交于 2020-01-06 06:43:08
问题 I'm trying to write some VBA in Outlook to count emails in the inbox folder (unread and read) every hour and to dump something like the below to a text file each time that happens: 28/02/2018 01:00 - 1,320 I've seen various code snippets, but I'm not sure how to achieve this. Could someone help please? 回答1: Should be simple to do that- Example Option Explicit Public Sub example() Dim Items As Outlook.Items Set Items = Application.Session.GetDefaultFolder( _ olFolderInbox).Items Debug.Print

outlook vba select messages in sub-folder

五迷三道 提交于 2020-01-06 02:19:09
问题 Outlook 2007 is configured with two email accounts: Account#1: Hotmail Account#2: Gmail I would like to create a macro named simulating a user doing the following: Left click on a within either the hotmail or gmail account. Highlight all messages within the folder previously selected. display a messageBox with the number of emails selected from this folder I have tried several methods to define the folder, but its not working. My suspicion is it would work on the default PST, but that isn't

Deleting Signature After CreateItemTemplate

不羁岁月 提交于 2020-01-06 01:58:28
问题 I am using the below code that I found for a new template but I want to delete the signature. I either need code to delete the signature after the below code or a completely new code that opens a new email, clears body then inserts template. Sub NewTemplate() Set objMsg = Application.CreateItemFromTemplate("S:\filepath.oft") Set newItem = Nothing With objMsg .SentOnBehalfOfName = "email@email.com" .Display End With End Sub 回答1: Set objDoc = objMsg.GetInspector.WordEditor If objDoc.Bookmarks

Retain formatting when copying from word to outlook

爷,独闯天下 提交于 2020-01-05 17:49:10
问题 I have a code which replaces the text of certain format into a hyperlink. This code works during an incoming email. Incoming email -> copy the email to word editor(formatting lost) -> make necessary changes -> copy from word editor to outlook mail item(again replaced hyperlinks gets lost in mail item) My code is here for your refernce.. Sub IncomingHyperlink(MyMail As MailItem) Dim strID As String Dim Body As String Dim objMail As Outlook.MailItem Dim strtemp As String Dim RegExpReplace As

VBA Try and Catch (MS Outlook)

时光毁灭记忆、已成空白 提交于 2020-01-05 11:18:27
问题 I use the following function to monitor a public Outlook folder for new E-Mails to arrive: Public Sub Application_Startup() Set NewMail = Application.GetNamespace("MAPI").Folders(3).Folders(2).... End Sub For some reason, the path to this public folder changes over time in a weekly period. What changes is the number in .Folders(3) . It varies from 1 to 3. Apparently, to keep the function working and to catch the error, when the path changes, I want to implement a try and catch function such

How do i capture the text in the Instant Search box in Outlook 2010 in vba

我是研究僧i 提交于 2020-01-05 09:35:41
问题 I've amended some code I found which will allow me to create a ribbon button to search back sixty days. Sub LastSixtyDays() Dim myOlApp As New Outlook.Application Dim tDate As Date tDate = Now - 60 txtsearch = "received: (" & Format(tDate, "dd/mm/yyyy") & ".." & Format(Now, "dd/mm/yyyy") & ")" myOlApp.ActiveExplorer.Search txtsearch, olSearchScopeCurrentFolder Set myOlApp = Nothing End Sub which works perfectly, but how do i append "txtsearch" to the existing contents of the Instant Search

Read an excel table in an outlook mail in vba

主宰稳场 提交于 2020-01-05 07:25:35
问题 I'm trying to read a table in my mail body and save it in a csv file (I attached an html sample below representing the content of my mail). I followed a related post: How to read table pasted in outlook message body using vba? but the problem is that it delimits the table by its cells and not its line so instead of getting 17 rows a one header I get 18 x 5 = 90 elements of an array...I tried to change the delimiter in the split option from "vbCrLf" to "vbLf", "vbCr", Char(10)...but none of

Outlook run macro when mail arrives on a nondefault mailbox

两盒软妹~` 提交于 2020-01-05 04:24:06
问题 I have multiple mailboxes set-up in my Outlook 2010. I would like a macro to run when I receive a mail on one of the non-default mailboxes. I have coded the below and inserted the code into "ThisOutlookSession" . I have gotten it to work for the default mailbox's inbox but not my nondefault mailbox's inbox. When I try to re-open outlook 2010 having inserted the code, It tells me : "Compile error in hidden module: ThisOutlookSession". The non-default box is called 'abc.asia'. I am new to vba