This macro scans all messages in a folder, looking for a unique keyword and if found, enters a user name into the Billing Information field.
Usage scenario: multiple people send email from a shared mailbox. Each person is has a unique code in the signature they use that identifies who is handling the message. The manager wants scan the message list to see who is the message. To do this, the actual sender's name needs to be added to a field - since few sites use the billing information field, it is suitable for this purpose.
To use, the manager runs the macro on the Inbox (or selected folder). The If.. end if block needs to be repeated for each user. A function using an array of keywords and user names would be better.
To add a value to the billing information field when a message is sent, use the second macro.
Public Sub SetBillingField() Dim itm As Object Set Items = Application.ActiveExplorer.CurrentFolder.Items For Each itm In Items If InStr(1, itm.Body, "keyword", vbTextCompare) > 0 Then itm.BillingInformation = "user name" itm.Save End If Next Set itm = nothing End Sub
Add data to Billing Information field after message is sent
Use this to add data to the billing information field when the sent message is added to the Sent Items folder.
Dim WithEvents sentMsg As Items Private Sub Application_Startup() Dim NS As Outlook.NameSpace Set NS = Application.GetNamespace("MAPI") Set sentMsg = NS.GetDefaultFolder(olFolderSentMail).Items Set NS = Nothing End Sub Private Sub sentMsg_ItemAdd(ByVal Item As Object) Item.BillingInformation = "code" Item.Save End Sub
Add data to the Billing Information field when sent
Warning: when you use the ItemSend method, the recipient may be able to see the billing information.
Private Sub Application_ItemSend(ByVal Item As Object) Item.BillingInformation = "code" End Sub
Greetings
1:- I want that macro pick up mails from outlook which contain subject line either "ABC" or "RE: ABC".
2:- I want that macro pick up mails from outlook which contain subject line either "ABC" or "RE: ABC" and also Body contain "APPROVAL" word.
so macro save these mails as a PDF in desired Location.
Please help.
Thanks in advance,
Regards'
Rahul Rawat
Thank you for informative tips.
In the meantime, the billing information included in the email is stripped out when received. Is there any option to send email as it is, without losing such info?
If you use rtf message format, the field should remain, but that only works with outlook and is best within an organization using exchange mailboxes.
Thank you for the comment. The message in rtf format is received by outlook 2013. But, the result is the same, with null in the BillingInformation field. The following is my codes. Kindly take a look if there is anything I missed.
Thank you in advance.
-------------------------------------------------------
Dim olApp As Outlook.Application
Dim myItem As Outlook.MailItem
Dim myInspector As Outlook.Inspector
Dim wdDoc As Word.Document
Dim wdRange As Word.Range
Set olApp = New Outlook.Application
Set myItem = olApp.CreateItem(olMailItem)
myItem.BillingInformation = "Case_Folder"
myItem.Display
'Copy from MS word--------------------------
Set myInspector = myItem.GetInspector
Set wdDoc = myInspector.WordEditor
If Not (wdDoc Is Nothing) Then
Set wdRange = wdDoc.Range(0, wdDoc.Characters.count)
wdRange.Paste
End If
myItem.Save
myItem.Send
Set wdRange = Nothing
Set mdDoc = Nothing
Set myInspector = Nothing
Set myItem = Nothing
Set olApp = Nothing
Hi,
I am looking for Macro in outlook 2007 , where i want to restrict few mail id like abc@gmail.com, xyz@gmail.com, whether it is appearing in the "To" "CC" or "BCC" option and secondly only prime mail id can send the mails to above e.g. 123@gmail.com.
Case:-
If 123@gmail.com is sending the mail to abc@gmail.com or xyz@gmail.com then it is good to go. 234@gmail.com is sending then it should give the prompt that you are not authorized to send the mail.
Hope you will able to make out what i am looking for.
Thank you
I have a macro here somewhere that checks addresses. It's basically the macro here but with different conditions.