Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending an email to Outlook in a specific folder

Status
Not open for further replies.

dlamarche

Instructor
Oct 20, 2003
11
CA
Hello. I created a small application using Access 2K that sends emails using Outlook 2K. Until recently everything went fine. Something was changes in the Exchange server and all email are automatically sent without the user having the chance to review it.

It happens often that the user needs to make small custom modifications to the email before sending it. My idea was that perhaps the Access code could sent all emails to a folder other than the default Outbox folder. Now the person could review them before moving them to the Outbox. This is the code that I use:

Public Sub SendReceipt(strCorrespondentTitle As String, _
strCorrespondent As String, _
strCorrespondentLang As String, _
strEmail, _
strAuthorList As String)

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Dim strManuscriptName As String
Dim strMessageSubject As String
Dim strMessageBody As String

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

strMessageBody = strMessageBody & "Message here"

With objOutlookMsg
Set objOutlookRecip = .Recipients.Add(strEmail)
.Subject = strMessageSubject
.HTMLBody = strMessageBody
.SaveAs
.Send
End With

Set objOutlookRecip = Nothing
Set objOutlookMsg = Nothing
Set objOutlook = Nothing

End Sub

Is there a way that I can stop the email from being sent and create it into another folder instead?

Thank you very much.

Daniel Lamarche

 
I've only manipulated the Outlook object model from Excel, and I'm not sure how you could put the message into a specific folder instead of sending it.

However, if I understand your intent, you don't need to. You should be able to replace the ".Send" with ".Display" . You will also need to comment out:
Code:
    'Set objOutlookRecip = Nothing
    'Set objOutlookMsg = Nothing
    'Set objOutlook = Nothing
That should make the email pop up in a new window when it is created so the user can review it before they click "Send".



VBAjedi [swords]
 
Hey thanks very much! That's exactly what I needed. Using the .Display method did what you mentionned.

I really appreciate your kind contribution. I'm not bad at VBA in Access but in other app heu... not at all!

Thanks again!
 
Hi,
I am trying to do something similiar.
I am looping thru a list of emails to send(20-50)and I want to put them in the outbox and let send and recieve take care of it. I can't seem to find any code in the forum to do this instead of a send.
Any help is appreciated.
Len
 
As far as I can tell, you can't create items in the Outbox folder. However, you can create them in the Drafts folder, which is problably what you want. Do something like:

set msg=getnamespace("MAPI").getdefaultfolder(olFolderDrafts).items.add
msg.subject="Hello"
msg.body="My body"
...etc...
msg.save


Rob
[flowerface]
 
Thanks
But I need to automate the process.
I wanted to use the outbox because you can set outlook to periodically send and recieve.
I was trying to avoid the security problems and having to use the serenity email package.
Any other thoughts.
Len
 
Serenity? Do you mean Redemption?

AFAIK the Outlook security prompt is triggered when you create a new mail item, regardless of what you do with the item after you create it. I've never read of someone successfully bypassing the prompt that way.

There is a lot of material in this forum and on the web dealing with the Outlook security issue. Several workarounds exist, but all have drawbacks. . . Google "Outlook Redemption" to learn more.

Personally, I just keep a box running Outlook 97, which lets me generate emails to my hearts content. The latest version of Outlook indicates Microsoft is making efforts to find a better way, and I'm hoping to hold out until they come up with a solution.

LOL



VBAjedi [swords]
 
Thank you Rob for your suggestion. I will try it out when I will have a few minutes.

Thanks again guys, your suggestions were all appreciated. Now my customer is happy I can tackle other interesting problems.

Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top