![]() |
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
|
|||
|
|||
![]()
Greetings, geniuses.
I have a standard CDO send sub that works just dandy, except for one small detail. For each email there will be a variable amount of attachments - anywhere from 1 to maybe 15 tops. In the .With statement, I have this (all required statements beforehand are present. I'm just omitting them here for space's sake.): [code] 'looped for each email sent With iMsg Set .Configuration = iConf .To = EML 'email address from database .CC = "" .BCC = "" .From = " .Subject = Subj 'defined in the db .TextBody = strbody 'defined in the db .AddAttachment (Atch1) 'AHA!! Here's the rub!! .Send End With [\code] How may I: a) Loop around the .AddAttachment statement to add the required attachments, or b) define a variable that would contain the necessary attachment values (Atch1), and have the statement needed only once, and c) which is best or does it matter? I've seen solutions for non-CDO programs and earlier OL versions but I'm wary since what I'm doing is different, and spending 2 or 3 hours trying to force something that won't work anyway is demoralizing. Please ask for whatever additional and needed items I have mindlessly omitted, and thanks in advance!!! |
Ads |
#2
|
|||
|
|||
![]() Whereever you get the filenames of the attachments from, loop through it, for instance with: for i=1 to count .... next -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Am Wed, 24 Feb 2010 22:05:12 +0000 schrieb corquando: Greetings, geniuses. I have a standard CDO send sub that works just dandy, except for one small detail. For each email there will be a variable amount of attachments - anywhere from 1 to maybe 15 tops. In the .With statement, I have this (all required statements beforehand are present. I'm just omitting them here for space's sake.): Code: -------------------- 'looped for each email sent With iMsg Set .Configuration = iConf .To = EML 'email address from database .CC = "" .BCC = "" .From = " .Subject = Subj 'defined in the db .TextBody = strbody 'defined in the db .AddAttachment (Atch1) 'AHA!! Here's the rub!! .Send End With [\code] How may I: a) Loop around the .AddAttachment statement to add the required attachments, or b) define a variable that would contain the necessary attachment values (Atch1), and have the statement needed only once, and c) which is best or does it matter? I've seen solutions for non-CDO programs and earlier OL versions but I'm wary since what I'm doing is different, and spending 2 or 3 hours trying to force something that won't work anyway is demoralizing. Please ask for whatever additional and needed items I have mindlessly omitted, and thanks in advance!!! |
#3
|
|||
|
|||
![]()
[quote='Michael Bauer [MVP - Outlook];341979']Whereever you get the filenames of the attachments from, loop through it,
for instance with: for i=1 to count .... next -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Herr Bauer: Vielen dank fur die Hilfe . . . And it accomplished the attaching quite well. The next issue, though, and it should be simple (I just don't know where to look) is to clear the Atch1 variable so I don't accumulate attachments on each successive send: [code] For i = 2 To z If Range("A" + CStr(i)) = "" Then GoTo 27 Subj = Range("C" + CStr(i)) EML = Range("E" + CStr(i)) ID = Range("B" + CStr(i)) Call TextBody(i, strbody) y = 0 With iMsg Set .Configuration = iConf .To = EML .CC = "" .BCC = "" .From = " .Subject = Subj .TextBody = strbody Do While Range("B" + CStr(i + y)) = ID DocName = Range("D" + CStr(i + y)) Atch1 = "C:\Huge\Medium\Small\" + DocName + ".pdf" .AddAttachment (Atch1): y = y + 1 Loop .Send End With 27 Next [\code] Each successive email has all the attachments that previous emails have had plus the new ones. I am sure it's an elementary command, but CDO statement catalogs are hard to come by. And I know it's simple - I'm good at simple. Noch einmal danke sehr. |
#4
|
|||
|
|||
![]() The variable is cleared, or overwritten respectively, automatically as soon as you write the next file name into it. However, atch1="" will also do it. -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Am Fri, 26 Feb 2010 21:39:48 +0000 schrieb corquando: 'Michael Bauer [MVP - Outlook Wrote: ;341979']Whereever you get the filenames of the attachments from, loop through it, for instance with: for i=1 to count .... next -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Herr Bauer: Vielen dank fur die Hilfe . . . And it accomplished the attaching quite well. The next issue, though, and it should be simple (I just don't know where to look) is to clear the Atch1 variable so I don't accumulate attachments on each successive send: Code: -------------------- For i = 2 To z If Range("A" + CStr(i)) = "" Then GoTo 27 Subj = Range("C" + CStr(i)) EML = Range("E" + CStr(i)) ID = Range("B" + CStr(i)) Call TextBody(i, strbody) y = 0 With iMsg Set .Configuration = iConf .To = EML .CC = "" .BCC = "" .From = " .Subject = Subj .TextBody = strbody Do While Range("B" + CStr(i + y)) = ID DocName = Range("D" + CStr(i + y)) Atch1 = "C:\Huge\Medium\Small\" + DocName + ".pdf" .AddAttachment (Atch1): y = y + 1 Loop .Send End With 27 Next [\code] Each successive email has all the attachments that previous emails have had plus the new ones. I am sure it's an elementary command, but CDO statement catalogs are hard to come by. And I know it's simple - I'm good at simple. Noch einmal danke sehr. |
#5
|
|||
|
|||
![]()
Alrighty, then . . .
I'd tried that, but it still 'stacked up' the attachments; then I noticed that I had only one CDO session opened, and was looping through the records within that one session. Evidently the session was remembering the attachments and sending them as they piled up. What I finally did (using the 'Atch="" ' command) was to loop through the records, opening and then closing a CDO session for each email. It still went just as fast, so evidently that's acceptable. Thanks and best regards! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
OL2K7 - Reset holidays in Calendar? | Tony[_2_] | Outlook - General Queries | 3 | November 20th 09 08:18 PM |
OL2k7 POP3/SMTP settings | Alex | Outlook - Installation | 0 | October 25th 08 09:38 AM |
Coding Multiple Variable Attachments for Appointments in VBA | Joe Jacobs | Outlook and VBA | 1 | July 21st 08 09:06 PM |
Configuring OL2K7 with OL Connector to be the Default | Ed V[_2_] | Outlook - Installation | 3 | May 2nd 08 06:05 PM |
How to change account for the Outlook Connector/OL2K7 | Paul Miner | Outlook - Installation | 2 | May 2nd 08 12:18 AM |