cancel
Showing results for 
Search instead for 
Did you mean: 

Outlook Send emails from Draft Folder ...

Anonymous
Not applicable
Hi, i want to send emails from the Draft folder, i'm stuck with namespace errors, i have used below code. is there a best way to achive it using VB or C#   -------------------------------------------code--------------------------------------------------   Public Sub SendDrafts() Dim lDraftItem As Long Dim myOutlook As Outlook.Application Dim myNameSpace As Outlook.NameSpace Dim myFolders As Outlook.Folders Dim myDraftsFolder As Outlook.MAPIFolder 'Send all items in the "Drafts" folder that have a "To" address filled in. 'Setup Outlook Set myOutlook = Outlook.Application Set myNameSpace = myOutlook.GetNamespace("MAPI") Set myFolders = myNameSpace.Folders 'Set Draft Folder. Set myDraftsFolder = myFolders("Mailbox - Your Name").Folders("Drafts") 'Loop through all Draft Items 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 'Send Item myDraftsFolder.Items.Item(lDraftItem).Send End If Next lDraftItem 'Clean-up Set myDraftsFolder = Nothing Set myNameSpace = Nothing Set myOutlook = Nothing End Sub
0 REPLIES 0