outlook-vba

How to move all messages in a conversation?

自古美人都是妖i 提交于 2019-12-19 04:34:47
问题 I need to know how to move all of the messages in a conversation at once. My macro currently reads Sub Archive() Set ArchiveFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders("Archive") For Each Msg In ActiveExplorer.Selection Msg.UnRead = False Msg.Move ArchiveFolder Next Msg End Sub But that only moves the latest message... and only when the conversation is fully collapsed! I can't Archive when the conversation is expanded. 回答1: If you want to handle

EXCEL VBA code to retrieve sharedmailbox all mails from root folders to subfolders

旧巷老猫 提交于 2019-12-18 09:44:51
问题 I have a code currently which I think should pull all mail items specified from only default folder. It's not working as I expected. I know there is some problem in looping all folders in shared mail box from root. How can fix it? Dim OutlookApp As Outlook.Application Dim OutlookNamespace As Outlook.Namespace Dim olShareName As Outlook.Recipient Dim Folder As MAPIFolder Dim eFolder As Outlook.Folder Dim olItems As Outlook.Items Dim OutlookMail As Variant Dim arrResults() As Variant Dim

Why does Attachments.Count return 0 on incoming mail with attachments?

為{幸葍}努か 提交于 2019-12-18 09:40:06
问题 I'm trying to save attachments automatically to a local folder using Outlook 2010. It works when I first create the rule and apply it to all inbox. It doesn't work with incoming mail (no file was saved). I tried adding some weird code and it fired errors so the script ran. Public Sub saveAttachtoDisk(itm As Outlook.MailItem) Dim objAtt As Outlook.Attachment Dim saveFolder As String saveFolder = "C:\temp" Dim dateFormat As String dateFormat = Format(itm.ReceivedTime, "yyyy-mm-dd Hmm ") For

Outlook rename attachments and save to folder

你离开我真会死。 提交于 2019-12-18 09:25:36
问题 I have a script that I found that currently saves attachments but I also need it to rename those attachments to the same name. For a little background I am creating a system that updates inventory on one of my websites. To do this I get a report(CSV) from our ERP with all my item numbers and inventory counts. They are emailed to me but the attached CSV always has a name that ends in a different number. I need the file to have the same name every time because the script I have saves that CSV

How to filter items sendername from Items_ItemAdd Events?

天大地大妈咪最大 提交于 2019-12-18 08:58:40
问题 Private WithEvents Items As Outlook.Items Private Sub Application_Startup() Dim Ns As Outlook.NameSpace Dim Folder As Outlook.MAPIFolder Set Ns = Application.GetNamespace("MAPI") Set Folder = Ns.GetDefaultFolder(olFolderInbox) Set Items = Folder.Items End Sub Private Sub Items_ItemAdd(ByVal Item As Object) If TypeOf Item Is Outlook.MailItem Then Printattachments Item End If End Sub I made a rule so outlook will automatically print any incoming email with attachment, with exception of few

Detect end of new message in email conversation body

寵の児 提交于 2019-12-18 08:54:45
问题 When a message gets replied or forwared the previous thread gets appended on your new mail by placing i.e. ----Original Message---- in front of it. Outlook does the same with tekst messages but with HTML mails it shows a line followed with From:.. Since outlook shows a line in between these messages i believe it's possible to subtract these messages using VBA. But How? Goal: When the user sends a mail (Application_ItemSend) I want to scan the message for certain words. But I don't care if it

Reference a folder by name

南楼画角 提交于 2019-12-18 07:11:40
问题 I need to get a folder by name, not by folder number counts. I tried getting with various methods. Dim olApp As Outlook.Application Dim objNS As Outlook.NameSpace 'Dim OlFolder As Outlook.MAPIFolder Dim objFolder As Outlook.Folder Dim myolItems As Outlook.Items Set olApp = Outlook.Application Set objNS = olApp.GetNamespace("MAPI") 'Set myOlItems = objNS.GetDefaultFolder(37).Folders("Vijay Baswal").Items 'Open the folder Set objFolder = olApp.Session.GetDefaultFolder("Vijay Baswal") 回答1: Say

MS Access / Outlook 2010 - how to choose which account to send email from?

走远了吗. 提交于 2019-12-18 07:03:31
问题 I am trying to send emails from a specific account but it always sends from my main no matter how much code I try or what I do. Is there any way to tell it to send it from a particular account? I am writing my code in MS Access, but using Outlook objects. Sub testEmail() On Error Resume Next Set outapp = GetObject(, "Outlook.Application") If outapp Is Nothing Then Set outapp = CreateObject("Outlook.Application") End If Set oMail = outapp.CreateItem(olMailItem) With oMail .To = "randomaddress

Add BCC to email with VBA in Outlook 2013

陌路散爱 提交于 2019-12-18 05:48:09
问题 I can't figure out the correct VBA code for Outlook 2013 to add a fixed email address to the BCC field of an email while it is open for editing. I have the following code, which creates the email and then sets the BCC. I want to add BCC to emails that I am replying to, so the message will already be in 'draft' form. Sub sendcomment_click() Set oMsg = Application.CreateItem(olMailItem) With oMsg .Recipients.Add ("email address") 'Set objRecip = Item.Recipients.Add("email address") 'objRecip

Get item.recipient with Outlook VBA

和自甴很熟 提交于 2019-12-18 05:20:22
问题 I need to get the recipient email address out of an item on Outlook 2010. My code is as follow: sSQL = "SELECT id from dbo.database where email_address LIKE '" & Item.RecipientEmailAddress & "' item.recipientEmailAddress is not valid, but I need something like that. I know that you have a code call Item.SenderEmailAddress but in this case I need the recipient's email address. I've seen some other threads on that subject but I did not manage to make any of them work. 回答1: For a "quick" way of