A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Variable Attachments in CDO/OL2K7?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 24th 10, 10:05 PM
corquando corquando is offline
Junior Member
 
First recorded activity at Outlookbanter: Feb 2010
Posts: 7
Default Variable Attachments in CDO/OL2K7?

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  
Old February 25th 10, 08:48 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Variable Attachments in CDO/OL2K7?



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  
Old February 26th 10, 09:39 PM
corquando corquando is offline
Junior Member
 
First recorded activity at Outlookbanter: Feb 2010
Posts: 7
Smile

[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  
Old February 27th 10, 08:33 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Variable Attachments in CDO/OL2K7?



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  
Old March 2nd 10, 08:01 PM
corquando corquando is offline
Junior Member
 
First recorded activity at Outlookbanter: Feb 2010
Posts: 7
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 07:58 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.