?
Solved

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

Posted on 2006-06-19
5
Medium Priority
?
711 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 1000 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

718 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