I have a small code to send emails from a folder within the drafts in outlook 2007
I am trying to add a yes/no question message before the messages are sent, just incase someone click the button im attaching the code to by mistake.
VB is not really my thing, i have searched th web and found some codes for the message box but cant seem to intigrate them into this code and have it work
This is the code
Thsi is some code i have tried to add
i have tried putting this in the send items section of the main code
can anyone assist me
thanks
I am trying to add a yes/no question message before the messages are sent, just incase someone click the button im attaching the code to by mistake.
VB is not really my thing, i have searched th web and found some codes for the message box but cant seem to intigrate them into this code and have it work
This is the code
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
'Setup Outlook
Set myOutlook = Outlook.Application
Set myNameSpace = myOutlook.GetNamespace("MAPI")
Set myFolders = myNameSpace.Folders
'Set Draft Folder. This will need modification based on where it's
Set myDraftsFolder = myFolders("Mailbox - Yaketyyak").Folders("Drafts").Folders("statements")
'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
Code:
Dim msg As String Dim title As String Dim style As MsgBoxStyle Dim response As MsgBoxResult msg = "Do you want to continue?" ' Define message. style = MsgBoxStyle.DefaultButton2 Or _ MsgBoxStyle.Critical Or MsgBoxStyle.YesNo title = "MsgBox Demonstration" ' Define title. ' Display message. response = MsgBox(msg, style, title) If response = MsgBoxResult.Yes Then ' User chose Yes. ' Perform some action. Else ' Perform some other action. End If
can anyone assist me
thanks
Comment