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
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read this checklist to learn more about the 15 things you should never include in an email signature.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

724 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