Solved

Saving a copy of an email created with Outlook.MailItem after it has been sent.

Posted on 2006-06-19
5
701 Views
Last Modified: 2012-06-27
I have an access database with a form that has a button that i use to automatically create an email with some standard text for the body.

Sometimes my users would like to be able to edit the body before it is sent, so instead of automatically sending it I just display it and let them send it when they are finished.

I am trying to create a copy of the email to save in an extra folder in outlook. I can make of copy of the email after I initially create it but I don't have any of the extra comments that they would input, so i need to copy it after they send it.

Is there a way to catch the send event from inside my access database so i can make a copy of the mailitem object. (i.e. creating an object with events)

I have also thought about creating a rule in outlook that would save any email from the sent folder if it had my pregenerated heading but I would like to accomplish this through code so any new users can automatically use the program without me needing to remeber to set up outlook with the email rule.

I'm currently trying to save the EntryID of the mailitem so i can use it later to cycle through the sent folder and pull out any emails they sent from my program. I haven't gotten far with this in code but the logic flaw i come accross is decideing when i should run the method that does this.

Any help, suggestions and comments is greatly appreciated. Below is a copy of my code.

Dim appOutlook As Outlook.Application, ns As NameSpace
Dim olFolder As Outlook.MAPIFolder, olSent As MAPIFolder
Dim olMail As Outlook.MailItem, olMailCopy As Outlook.MailItem

Set appOutlook = New Outlook.Application
Set ns = appOutlook.GetNamespace("MAPI")
Set olMail = appOutlook.CreateItem(olMailItem)
Set olFolder = ns.GetDefaultFolder(olFolderInbox).Folders("SaveFolder")
Set olSent = ns.GetDefaultFolder(olFolderSentMail)

With olMail    
     .To = rsMgr![User_Email]
     .Subject = "# " & Me![Num] & " Standard Heading"
     .Body = rsMgr![StandardBodyText]
     .Display
     intMsgID = .EntryID
End With

Set olMailCopy = olMail.Copy  ' This is the previous code that saves the copy before they have a chance to edit the body text
olMailCopy.Move olFolder

For Each olMail In olSent.Items    ' This is the code that i was working with to cycle through the sent box but I have to find a way to run it after they send the email
     If olMail.EntryID = intMsgID Then
          Set olMailCopy = olSent.Items()
     End If
Next
           
End Sub

Thanks,
Jason
0
Comment
Question by:CanIJay
[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
  • 2
5 Comments
 
LVL 34

Expert Comment

by:jefftwilley
ID: 16935680
Hi Jason,
Interesting what you're trying to do. And this may seem rather off point, but how about making your e-mail address a BCC and simply have the e-mail delivered to your inbox. You can create a rule then to move the e-mail to your save folder.
J
0
 
LVL 38

Accepted Solution

by:
Jim P. earned 250 total points
ID: 16935734
Why not put a memo field in you DB and then on the a text box bound to that field. Then they type the text in the DB and you just put that in the body of the e-mail as well?
0
 

Author Comment

by:CanIJay
ID: 16935763
I'm trying to avoid using outlook rules to copy the email becuase the user base of my program will switch at any given time to new employees but the mailbox they all share will always be the same. So when a new employee switches roles and begins using my program I may not get notified by the managers and I will be unable to set the rule up on their computer.

If my program was able to directly copy the email to the known folders I won't have to worry about creating the rules on the new computer. I thought of a similar rule set up for the sent items box because my heading would always contain similar terminology so a rule would be easy to pick out my emails.

Thanks for the suggestion
Jason
0
 

Author Comment

by:CanIJay
ID: 16935824
jimpen

I've previously ruled out this method becuase of screen layout and my table structure, but this may be the route that I will have go. I'd still like to see if there are any coding methods that would allow me to watch the send event. I highly doubt it though.

Thanks,
Jason
0
 
LVL 38

Expert Comment

by:Jim P.
ID: 17170461
Glad to be of assistance. May all your days get brighter and brighter.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

627 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