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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Outlook draft and keep it 1

Status
Not open for further replies.

Mollethewizard

IS-IT--Management
Nov 18, 2002
93
0
0
SE
I’ve searched the web and found the following code to send a draft and the code works fine. But with one exception – the draft is sent and removed from the drafts folder. Is it possible to modify the code so the draft is sent and kept for recycling? The content of the draft is sent several times per day and it would be nice to create a dialog box in a Word-document for the task. That bit I can manage.

The code so far:

Sub SendDraft()
Dim lDraftItem As Long
Dim myOutlook As Object
Dim myNameSpace As Object
Dim myFolders As Object
Dim myDraftsFolder As Object
Set myOutlook = CreateObject("Outlook.Application")
Set myNameSpace = myOutlook.GetNamespace("MAPI")
Set myFolders = myNameSpace.Folders
Const olFolderDrafts = 16
Set myDraftsFolder = myNameSpace.GetDefaultFolder(olFolderDrafts)
For lDraftItem = myDraftsFolder.Items.Count To 1 Step -1
'Check for "To" address and only send if "To" is filled in.
'If Len(Trim(myDraftsFolder.Items.item(lDraftItem).To)) > 0 Then
If (myDraftsFolder.Items.item(lDraftItem).Subject) = "Rexlösenord_win7" Then
'myDraftsFolder.Items.item(lDraftItem).Send
myDraftsFolder.Items.item(lDraftItem).To = "NN@NN.se"
myDraftsFolder.Items.item(lDraftItem).Send
End If
Next lDraftItem
'Clean-up
Set myDraftsFolder = Nothing
Set myNameSpace = Nothing
Set myOutlook = Nothing
End Sub

Greetings Christer
 
Send a copy:
Code:
If (myDraftsFolder.Items.item(lDraftItem).Subject) = "Rexlösenord_win7" Then
    With myDraftsFolder.Items.item(lDraftItem).Copy
        .To = "NN@NN.se"
        .Send
    End With
End If


combo
 
What do you mean by "sent and kept for recycling"?

I would expect to find a sent item/draft in the Sent Items folder. Would you be better suited either:
1. using an Outlook Template, or
2. creating the mail 'on the fly'?

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Combo - Life is simple when you know how to code yourself through it. Thanks ever so much - that code works perfectly.
CluelessChris – what I ment was that I’ve got several drafts whit instructions that I send to different people every day. I want to send the draft and keep it in the same time for “recycling”.
 
To re ask CluelessChris' question, why not use a TEMPLATE?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top