Automatically take specific data out of specific emails and put it into an excel form - vba

I'm completely new to VBA.
Is it possible to write some code that would search for emails from a specific sender and search inside that email for a specific line in a table, which it would then put into an already existing excel form?
Any advice on where to get started learning this or if it's even possible would be greatly appreciated.

it is possible to make that. You have three types to search something like that.
You have the View, AdvancedSearch and the Explorer.Search.
The View is only for one folder.
The Filter for the View is called Distributed Authoring Search and Location (DASL). Here is a good link for that filter type: https://msdn.microsoft.com/en-us/library/ms874577(v=exchg.65).aspx
The AdvancedSearch is like the View, but you can search over all folders and all nameboxes. BUT there is problem! When you use AdvancedSearch you have to create an folder and in this folder are your results. The filter of the folder is unchangebel, so after creading you cant change anything. The folder will update Automaticly if there are new Mail or something else. The AdvancedSearch uses the same filter as View.
The last one is the Explorer.Search. With that search you can search like the AdvancedSearch, but you have not to create an folder. This one uses the Advanced Query Syntax (AQS). Here is a good link for that filter type: https://msdn.microsoft.com/en-us/library/cc513841(v=office.12).aspx Each of the searches can filter for all typs of objects. So you can Search for things in Mails.
Text in mails is Called in..
- DASL textdescription.
- AQS contents.
I hope I could help you by starting.

Related

How to Move Emails Containing Name of a Folder?

We manually create a folder each time we get a new client.
I'd like if an email contains a keyword that matches the name of a folder, then move the email to said folder.
E.g.
If email in inbox contains keyword "Apple" and an "Apple" folder exists, then move email to the "Apple" folder. Else nothing.
Similarly, if email in inbox contains keyword "Google" and a "Google" folder exists, then move the email to the "Google" folder. Else nothing.
Without having to set rules for each new folder that is created.
Yes, it is possible. In VBA you can scan all folders for email with a specific keyword and if a corresponding folder exists in Outlook you could move it to that folder. Let's consider what needs to be done for that. First, you need to scan all folders. The AdvancedSearch method of the Application class allows to perform a search based on a specified DAV Searching and Locating (DASL) search string. The key benefits of using the AdvancedSearch method in Outlook are:
The search is performed in another thread. You don’t need to run another thread manually since the AdvancedSearch method runs it automatically in the background.
Possibility to search for any item types: mail, appointment, calendar, notes etc. in any location, i.e. beyond the scope of a certain folder. The Restrict and Find/FindNext methods can be applied to a particular Items collection (see the Items property of the Folder class in Outlook).
Full support for DASL queries (custom properties can be used for searching too). To improve the search performance, Instant Search keywords can be used if Instant Search is enabled for the store (see the IsInstantSearchEnabled property of the Store class).
You can stop the search process at any moment using the Stop method of the Search class.
Read more about that in the Advanced search in Outlook programmatically: C#, VB.NET article.
So, you could run a search for items in the background and then at some point when the search is completed you may be notified.
To find the target folder you could iterate over all folders in Outlook recursively. See Enumerate folders for more information on that.
Finally, to move items you can use the Move method which moves a Microsoft Outlook item to a new folder.

Get document's name with it's description

Trying to get the name of the active window with it's description, can't find any method.
My problem is that while I can access document's file name with Document.Name, I can't get the commentaries that Word attaches to it, like (Compatibility Mode, Last modified by User etc), without them, the method Windows(Document.Name) doesn't work, is there any solution for this?
My program opens four new documents and switches in a loop the active document, taking information from the original and putting some excerpts in the new ones.
Everything works when there is no commentaries for documents, but as they appear, program breaks, saying:
5941 The requested member of the collection does not exist
Thanks for reading!
This:
Windows(1).Document
will give you the document associated with a window. (You may need to loop through the windows to find the one you're interested in.)
Once you have the document you can access its properties:
Windows(1).Document.CompatibilityMode
Hope that helps

Delete default signature in Outlook and replace with content from doc/htm file

My workplace has introduced an draconian new uniform signature across the entire business which looks absolutely repulsive, and I can't in good conscience email clients without having to manually change it every single time.
I'm assuming it's being created via a macro that runs at start up. I'd like to set up a macro that I can activate from the ribbon that deletes the default signature that is in place when Outlook starts, and replace it with a new signature that is sourced (including formatting) from either a doc or a html file.
I've been searching for a couple of hours and can't find any macro code that either a) deletes a signature or b) allows for the creation of a new one by way of data from another file.
Can VB do what I'm looking for?
Many thanks in advance!
If you can't change the default signature for your e-mail account with the Outlook Options, take a look at
C:\Users\%username%\AppData\Roaming\Microsoft\Signatures
You will find the HTML files containing your signatures. Edit it directly...
Create a new signature, that way you only need to select it from a drop-down menu in the ribbon, and the policies that enforce the default will not see the custom one.

How to add crawl rule to the SharePoint 2010 fast search

We have one Document Library with some set of columns like Type, Name, Active.
We have already configured the SharePoint Fast Search to search the content in the site.
When I am searching with any particular keyword that showing the result as expected.
We got requirement that need to exclude the content form the doc library when the column “Active” is set to ”No”.
Could you please suggest me how can I add crawl rule for the particular doc library.
You are asking to fulfill this requirement using crawl rule. But crawl rule is generic for the content source and it will effect all the content source which is not recommended(and also not possible) for excluding some result depending on item values. So I like to solve this using scope which is described below.
For excluding that, first of all you need to add new managed property for the column "Active".
For that go to search service application-> Managed Property-> New managed property. Give property name and map it to the field "Active". Also select the type of the field "Active". Tick the box for allow this property to be used in scopes.
Then go to corresponding scope-> new rule-> choose property query
then choose from "Add property restriction" corresponding managed property name(property name given by you during managed property creation) and "=" "No"(please use exact field value of the document library), then choose Exclude and click "ok".
Add this scope in the search page and run full crawl in the central admin.
I hope this will fulfill your requirement.

Using the Addressbook in Outlook VBA

Someone at work asked me if I could implement an easy system for him to send out Outlook template-mails based on a few parameters he could enter.
An example would be a message like this:
"Hello,
Please be informed that system **Parameter1** is current down.
Regards,"
I was thinking about making a Form in Outlook VBA that would dynamically look for the amount of times a string styled like a parameter (e.g. ##parameters##) was found in a certain template and subsequently create a editbox in the form for each found parameter.
The problem is that I obviously would like to add an box for the recipients. I would need to find a way to make the call the Outlook Addressbook and make it behave like one. This was less intuitive than I had hoped. So far I have only managed to do the following:
Dim snd As Outlook.SelectNamesDialog
Dim displayLL As Boolean
Set snd = Application.Session.GetSelectNamesDialog()
snd.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowTo
snd.AllowMultipleSelection = True
displayLL = snd.display()
As you can see, this only pops up the addressbook and allows me to select an few addresses. But I'm stumped on how I can actually make some fields that will actually act like the "To:" and "CC:" fields in a regular Outlook mail.
Not sure how relevant this is, considering I eventually took quite a different route, but I thought I'd still add this since no-one answered.
I simply created a form that would list all templates by searching through the templates folder in the %AppData%. I would then loop through the entire mail looking for parameter-styled strings and ask for the desired value each time I would encounter such a string (through a simply inputbox). Instead of adding a custom "recipients" box, I simply opened a new mail with the parameters filled out correctly.
The user could then simply add recipients to the mail like he usually would, and he was fine with this. That way, he was also able to double-check if the mail indeed looked exactly like he wanted to.
Nothing fancy or something that a 7-year old wouldn't be able to do, but it works.