Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple attachments on E-mails

Status
Not open for further replies.

jmc014

Technical User
Nov 24, 2007
80
ES
Following on from thread181-75403
I would like to know if it is possible to add multiple attachements by looping through a series of records:

Amongst others, I have a felid called NDCLink in a one of my DB's. I was thinking of being able to loop through those records where [Check] is equal to true and include the info from the [NDCLink] feild to ceate a list of multipe attachements that have to the included in my email (Not sure if this can be done?)


Here is below is an extract of what I'm trying:


If Forms!MainScreen!Check!= True Then

Set Re = CurrentDb.OpenRecordset("SELECT * FROM Header WHERE Check = True")
Do While Not Re.EOF


AttName= Forms!MainScreen!NDCLink & Re!NDCLink & "; "


CountOf = CountOf + 1
Re.MoveNext
Loop
End If


Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

With MailOutLook
.To = Whomever may be interested
.Subject = "<MySubject>"
.HTMLBody = "<BodyText>"

.Attachments.Add AttName

.Display
End With

End if

I've been reading though the threads that are issung multiple attachments and cannot find too much on how I can get this one to work.
Any ideas out there?

JMC014
 
Id you try to re-arrange your code like this:

Code:
If Forms!MainScreen!Check! = True Then

    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)

    With MailOutLook
        .To = Whomever may be interested
        .Subject = "<MySubject>"
        .HTMLBody = "<BodyText>"
        
        Set Re = CurrentDb.OpenRecordset("SELECT * FROM Header WHERE Check = True")
        Do While Not Re.EOF
            .Attachments.Add = Forms!MainScreen!NDCLink & Re!NDCLink & "; "
            CountOf = CountOf + 1  [green]'???[/green]
            Re.MoveNext
        Loop
        
        .Display
    End With
End If

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top