outlook-vba

IE automation via Outlook - Permission Denied issues

怎甘沉沦 提交于 2019-12-13 03:54:18
问题 Sub test() Dim objShell As Object Dim objShellWindows As Object Dim objWin As Object Set objShell = CreateObject("Shell.Application") Set objShellWindows = objShell.Windows For Each objWin In objShellWindows If TypeName(objWin.Document) = "HTMLDocument" Then Debug.Print objWin.Document.Location End If Next objWin End Sub This works perfectly fine in Excel, Access, Word and PowerPoint, but throws "Run-Time error 70 - Permission Denied" error on the Debug.Print line when ran from Outlook. I'm

Outlook Count Emails mark as Important

こ雲淡風輕ζ 提交于 2019-12-13 03:52:03
问题 Can someone point out what I am missing here. Every time I run this it says that an object is required. I apologize I feel like this is a very easy fix but I have been wrecking my brain for a while. Basically what I am trying to accomplish is count how many emails are mark as high importance. Again I feel like this is such a simple error but I am still learning this. Sub CheckForImportance() Dim myNs As Outlook.NameSpace Dim infldr As Outlook.Folder Dim impMail As Outlook.MailItem Dim

How to implement ItemChange for many Outlook subfolders?

江枫思渺然 提交于 2019-12-13 03:35:08
问题 In a VBA module in Outlook I have currently code like this: Private WithEvents AAInboxItems As Outlook.Items Private WithEvents AASentItems As Outlook.Items Private WithEvents AADoneItems As Outlook.Items Private Sub AAInboxItems_ItemChange(ByVal Item As Object) 'Do Something End Sub Private Sub AASentItems_ItemChange(ByVal Item As Object) 'Do Something End Sub Private Sub AADoneItems_ItemChange(ByVal Item As Object) 'Do Something End Sub Above is not the complete code, just to show the

Modify HTMLBody of Outlook Email, based on Template, from Excel

拟墨画扇 提交于 2019-12-13 03:30:51
问题 I am trying to modify the HTML body of an Outlook email, based on a template, from Excel VBA. My code is: Sub Email_Button() Dim OutApp As Outlook.Application Dim OutMail As Outlook.MailItem Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItemFromTemplate("S:\some\path\to\file\Email.oft") With OutMail .Importance = olImportanceHigh .Subject = "Subject " & Date .Attachments.Add Application.ActiveWorkbook.FullName .HTMLBody = WorksheetFunction.Substitute(OutMail

outlook script that automatically opens links in emails

。_饼干妹妹 提交于 2019-12-13 03:23:11
问题 I am using windows 10 on my pc and use chrome most of the time for outlook. I am trying to get a script that automatically opens a link received in a email. I have found vba scripts but they do not work i keep getting errors. If any of you could help me out with this? 回答1: You can use the HTMLBody property of the MailItem class to find all hyperlinks there. Then you can use the following method to run Chrome with a link found: Sub LaunchInChrome (url as String) Dim chromePath As String

Looping through Arrays with VBA, to Move outlook emails from one folder to another?

∥☆過路亽.° 提交于 2019-12-13 03:20:29
问题 I want to move emails of invoices from a main folder to a different folder. I extracted the subject of the emails with VBA from outlook in the first module, they are in column 3. Then I manually write out the folder I would like the emails to move to, in column 8. (The names of the folder is a subfolder) Column 3 is the subject of the email which I extracted, I used the restrict method for outlook to return the email with the specific tittle Column 8 is the folder I would like the email to

Copy range of cells from Excel to body of email in Outlook

北战南征 提交于 2019-12-13 03:02:39
问题 How can I copy a range of cells from Excel to the body of an email in Outlook using VBA? I just need the content to be a body of the Outlook mail. 回答1: You can find a packaged solution here : http://www.rondebruin.nl/mail/folder1/mail4.htm Sub Mail_Range() 'Working in 2000-2010 Dim Source As Range Dim Dest As Workbook Dim wb As Workbook Dim TempFilePath As String Dim TempFileName As String Dim FileExtStr As String Dim FileFormatNum As Long Dim I As Long Set Source = Nothing On Error Resume

Setting the sender email address according to the recipient

…衆ロ難τιáo~ 提交于 2019-12-13 02:59:10
问题 How can I set programmatically in an email, to which I reply , the sender address to the recipient address? Is there a way in VBA? I don't know where to start so I apologize because I cannot show any code. 回答1: Credit to @Al Bundy for correcting this. This solution is based on this post. In ThisOutlookSession : Option Explicit Private WithEvents objMail As MailItem Private assignmentHandled As Boolean 'Set MailItem Private Sub Application_ItemLoad(ByVal Item As Object) If Item.Class = olMail

VBA Regex Replace Loop

纵饮孤独 提交于 2019-12-13 02:56:22
问题 Currently having issues with a regex replace loop for ticketing system formatting I am testing a segment of code that will regex match a specific format for a ticket number. The ticket number should be in a format of "INC01234567" (up to 8 numeric digits). The "INC" can be optional so that the user can just type in the ending number (IE 1234567) and the loop will add the additional "0's" to give the numeric amount up to 8 digits. Currently, however, I am stuck on a math logic issue where it

Check if email attachment is password protected before sending

和自甴很熟 提交于 2019-12-13 02:48:11
问题 I'm trying to check all my attachments before sending an email to see if they are password protected. Typically these will be Word, Excel or PowerPoint files. I've got as far as seeing if there are attachments. I don't know how to loop through each attachment in the mail file to see if each one is password protected. Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim attachments2 As Outlook.attachments Dim attachm As Outlook.Attachment If Item.attachments.Count > 0 Then Set