Req Help: Generating replies to emails in sent folder

A

aah-boy

Hi all,

I'm going crazy here ... I'm trying to scan the sent folder and
generate replies to emails that contain certain text. I cannot get
Outlook2000 to .send a newly created email message.

When I replace this...
Set ReplyMi = olMail.Reply
for this...
Set ReplyMi = olApp.CreateItem(olMailItem)

VBA objects to me using the .send method - why !!??

The following code works - but, I need to make 100% sure that the
sender is the same as the original sender of the email - ie. me. In
the outbox folder however, the 'from' column contains no entry.

Hope this is clear - my head is a little muddy right now.

Thanks for any help.
Dave

Sub Send_Emails_As_Replies()

Dim olApp As Outlook.Application
Dim olNs As NameSpace
Dim Fldr As MAPIFolder

Dim ReplyMi As MailItem
Dim olMail As MailItem

Dim orig_from As String
Dim orig_subject As String
Dim body_msg As String
Dim text_to_find As String

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderSentMail)

For Each olMail In Fldr.Items

If InStr(olMail.Body, "PM123456") > 0 Or _
InStr(olMail.Subject, "UK") > 0 Then

With olMail
orig_from = .SenderName
orig_subject = .Subject
'.Delete
End With

Set ReplyMi = olMail.Reply
With ReplyMi
.Body = body_msg & vbCrLf & vbCrLf & olMail.Body
.Send
End With
End If
Next olMail

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top