Solved

How do I write a macro to automatically process the subject heading of specific email addresses and paste these subjects into a text file?

Posted on 2003-11-19
2
394 Views
Last Modified: 2010-04-08
Hi Experts,

How do I write a macro to automatically process the subject heading of specific email addresses and paste these subjects into a text file?

The macro has to initiate upon receiving emails, check to see if the email is from  a specific email address and if it is, read the subject of the email into a text file.

Thanks!
0
Comment
Question by:indyng
2 Comments
 
LVL 4

Accepted Solution

by:
JeremyCrouch earned 500 total points
ID: 9782326
Private Sub Application_NewMail()  '<-- this must be in the 'ThisOutlookSession'
writeSubject                                 '<-- in the Microsoft Objects Project Folder
End Sub                                       '<--

Public Sub writeSubject()
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim message As MailItem
Dim filename As String

Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)

Set message = Inbox.Items(1)

If message.SenderName = "Crouch, Jeremy" Then  '<-- causes a security warning ;(
 filename = "C:\" & message.SenderName & "_Subjects.txt"  'or whatever
 Open filename For Append As #1
 Print #1, message.subject
 Close #1
End If
End Sub

This works however... and this is a big however. Due to recent security patches from microsoft anytime your try to get the sender of an email, a security warning pops up. That defeats the whole purpose of making this automatic. I've ran into this problem before and never found a way aroung this.

Sorry, but maybe the code is still usefull to you.
0
 
LVL 1

Author Comment

by:indyng
ID: 9782919
Great stuff! Thanks for the help!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
Outlook Free & Paid Tools
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now