473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Select message box problem

347 100+
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Sub SendDrafts()
  3. Dim lDraftItem As Long
  4. Dim myOutlook As Outlook.Application
  5. Dim myNameSpace As Outlook.NameSpace
  6. Dim myFolders As Outlook.Folders
  7. Dim myDraftsFolder As Outlook.MAPIFolder
  8. 'Send all items in the "Drafts" folder that have a "To" address filled
  9. 'Setup Outlook
  10. Set myOutlook = Outlook.Application
  11. Set myNameSpace = myOutlook.GetNamespace("MAPI")
  12. Set myFolders = myNameSpace.Folders
  13. 'Set Draft Folder.  This will need modification based on where it's
  14.  
  15. Set myDraftsFolder = myFolders("Mailbox - Yaketyyak").Folders("Drafts").Folders("statements")
  16. 'Loop through all Draft Items
  17. For lDraftItem = myDraftsFolder.Items.Count To 1 Step -1
  18. 'Check for "To" address and only send if "To" is filled in.
  19. If Len(Trim(myDraftsFolder.Items.Item(lDraftItem).To)) > 0 Then
  20. 'Send Item
  21.    myDraftsFolder.Items.Item(lDraftItem).Send
  22. End If
  23. Next lDraftItem
  24. 'Clean-up
  25. Set myDraftsFolder = Nothing
  26. Set myNameSpace = Nothing
  27. Set myOutlook = Nothing
  28. End Sub
  29.  
  30.  
Thsi is some code i have tried to add

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim msg As String
  3. Dim title As String
  4. Dim style As MsgBoxStyle
  5. Dim response As MsgBoxResult
  6. msg = "Do you want to continue?"   ' Define message.
  7. style = MsgBoxStyle.DefaultButton2 Or _
  8.    MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
  9. title = "MsgBox Demonstration"   ' Define title.
  10. ' Display message.
  11. response = MsgBox(msg, style, title)
  12. If response = MsgBoxResult.Yes Then   ' User chose Yes.
  13.    ' Perform some action.
  14. Else
  15.    ' Perform some other action.
  16. End If
  17.  
  18.  
i have tried putting this in the send items section of the main code

can anyone assist me

thanks
Jan 9 '09 #1
3 1701
QVeen72
1,445 Expert 1GB
Hi,

Code is all right, In MsgBox code,
' Perform some action.
Replace the Above Line With :
Call SendDrafts

Regards
Veena
Jan 10 '09 #2
colinod
347 100+
I get an errror at the
Expand|Select|Wrap|Line Numbers
  1. Dim style As MsgBoxStyle 
part of the code
Jan 12 '09 #3
OuTCasT
374 256MB
Expand|Select|Wrap|Line Numbers
  1.  
  2. Select Case MsgBox("Are you sure you want to delete?", MsgBoxStyle.YesNo)
  3. Case MsgBoxResult.Yes
  4. --do delete or whatever
  5. Case MsgBoxResult.No
  6. - exit and dont delete
  7. Exit Sub
  8. End Select
  9.  
Jan 15 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Randell D. | last post by:
Folks, I have a SELECT that returns with multiple records - It works when I have a LIMIT clause but when I try to include a GROUP BY clause, the select returns nothing (ie no records, no...
2
by: ghasem | last post by:
Dear mySQL community, I have once again turned to the user groups for a problem I cannot solve myself! Atually, I have read all I can from the newsgroups on this but I could not solve it myself....
5
by: Martin Feuersteiner | last post by:
Dear Group I'm having trouble with the clause below. I would like to select only records with a distinct TransactionDate but somehow it still lists duplicates. I need to select the...
2
by: RanDeep | last post by:
I have two nodes that both exist underneath the root node. They are linked, however, in the sense that one of the nodes contains a copy of an id that is used to refer to the other. However, when I...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
8
by: Jacob Arthur | last post by:
How would I go about using a custom select string that is passed from a form to the SelectCommand parameter of SqlDataSource? I tried: SelectCommand = "<% Request.Form("hdnSelect") %>" but I...
2
by: Sektor | last post by:
Hi guys, I have just a problem with the Select timeout parameter. The MSDN tells us: microSeconds The time-out value, in microseconds. A -1 value indicates an infinite time-out. I try to use...
16
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.