![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Using Outlook 2003, this script runs whne a users clicks a button to submit
emails with attachments with a different frequency. It basically gets FreqAtt.Value from another text box, LoopCount is used to count until it reaches FreqAtt.Value. CB1...CB20 are email addresses. They all check out fine. I used dialogue boxes before, during and after the IF statement and it displayes the right values. 1 2, 2 2. But if I used those values, the IF statement still isn't hit. (The IF statement that adds an attachment to the email). Without the IF statement the attachments work. Is there some kind of specific reason an IF wouldn't work here? Dim LoopCount LoopCount = 1 For I = 1 To NumberEmails.Value Set objMail = Application.CreateItem(0) If CB1.Value = True Then Set rcpt = objMail.Recipients.Add(CB1.Tag) End If If CB2.Value = True Then Set rcpt = objMail.Recipients.Add(CB2.Tag) End If ' ... (Code removed, it's all th same IF's all have corresponding End IF.) If CB19.Value = True Then Set rcpt = objMail.Recipients.Add(CB19.Tag) End If If CB20.Value = True Then Set rcpt = objMail.Recipients.Add(CB20.Tag) End If If CB1 + CB2 + CB3 + CB4 + CB5 + CB6 + CB7 + CB8 + CB9 + CB10 + CB11 + CB12 + CB13 + CB14 + CB15 + CB16 + CB17 + CB18 + CB19 + CB20 = False Then MsgBox ("No Emails Selected"), vbOKOnly End If objMail.Subject = SubjectLine + " " + CStr(I) objMail.Body = "Records Management Test Message " + CStr(I) MsgBox (" LoopValueBefo " & LoopCount & " " & FreqAtt.Value), vbOKOnly If FreqAtt.Value = LoopCount Then Set myAtt = objMail.Attachments myAtt.Add AttachmentPath.Value MsgBox (" LoopValue In IF: " & LoopCount & " " & FreqAtt.Value), vbOKOnly LoopCount = 0 End If MsgBox (" LoopValueAfter: " & LoopCount & " " & FreqAtt.Value), vbOKOnly LoopCount = LoopCount + 1 objMail.Save objMail.Send Next I |
#2
|
|||
|
|||
![]()
It appears to me that you're trying to compare LoopCount, a numeric value,
with the string value of a textbox control. You need to convert one or the other to a compatible format. Either convert LoopCount to a string value or the textbox value to a numeric value. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mitch" wrote in message ... Using Outlook 2003, this script runs whne a users clicks a button to submit emails with attachments with a different frequency. It basically gets FreqAtt.Value from another text box, LoopCount is used to count until it reaches FreqAtt.Value. CB1...CB20 are email addresses. They all check out fine. I used dialogue boxes before, during and after the IF statement and it displayes the right values. 1 2, 2 2. But if I used those values, the IF statement still isn't hit. (The IF statement that adds an attachment to the email). Without the IF statement the attachments work. Is there some kind of specific reason an IF wouldn't work here? Dim LoopCount LoopCount = 1 For I = 1 To NumberEmails.Value Set objMail = Application.CreateItem(0) If CB1.Value = True Then Set rcpt = objMail.Recipients.Add(CB1.Tag) End If If CB2.Value = True Then Set rcpt = objMail.Recipients.Add(CB2.Tag) End If ' ... (Code removed, it's all th same IF's all have corresponding End IF.) If CB19.Value = True Then Set rcpt = objMail.Recipients.Add(CB19.Tag) End If If CB20.Value = True Then Set rcpt = objMail.Recipients.Add(CB20.Tag) End If If CB1 + CB2 + CB3 + CB4 + CB5 + CB6 + CB7 + CB8 + CB9 + CB10 + CB11 + CB12 + CB13 + CB14 + CB15 + CB16 + CB17 + CB18 + CB19 + CB20 = False Then MsgBox ("No Emails Selected"), vbOKOnly End If objMail.Subject = SubjectLine + " " + CStr(I) objMail.Body = "Records Management Test Message " + CStr(I) MsgBox (" LoopValueBefo " & LoopCount & " " & FreqAtt.Value), vbOKOnly If FreqAtt.Value = LoopCount Then Set myAtt = objMail.Attachments myAtt.Add AttachmentPath.Value MsgBox (" LoopValue In IF: " & LoopCount & " " & FreqAtt.Value), vbOKOnly LoopCount = 0 End If MsgBox (" LoopValueAfter: " & LoopCount & " " & FreqAtt.Value), vbOKOnly LoopCount = LoopCount + 1 objMail.Save objMail.Send Next I |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Loop Attachment (once again) | Dan | Outlook and VBA | 6 | December 28th 09 04:49 PM |
Loop Attachment | Dan | Outlook and VBA | 0 | May 27th 09 04:18 AM |
Loop through future appointments | Daniel | Outlook and VBA | 2 | July 5th 07 02:30 PM |
CDO Loop problem - Fix could be useful for many people. | Sue Mosher [MVP-Outlook] | Outlook and VBA | 0 | March 30th 07 06:08 PM |
Reverse loop? | yonina | Outlook and VBA | 2 | February 2nd 06 10:10 AM |