dbTalk Databases Forums  

Sending E-mails with Outlook from A2002

comp.database.ms-access comp.database.ms-access


Discuss Sending E-mails with Outlook from A2002 in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dirk Goossens
 
Posts: n/a

Default Sending E-mails with Outlook from A2002 - 06-09-2006 , 10:01 AM






Hello!

I'm sending E-mails to mailadresses in a table, using the code below.
How can I send more than one attachment?
Access can find the file to be send in this field: MY_EMAILATTACHMENT_FIELD
I have also a field with the name MY_EMAILATTACHMENT_FIELD2
Combining the field names with an &-sign doesn't work, even when I put a ;
in between.
Thanks for a helping hand!

Dirk


= = = = = = WORKING CODE FOR A SINGLE ATTACHTMENT = = = = = = = =
Private Sub ButtonMakingMails_Click()

On Error GoTo LABEL1



Dim evFile As String

Dim Response As Byte

Dim rs As Recordset

Dim olApp As Outlook.Application, olItem As Outlook.MailItem



Set olApp = New Outlook.Application

Set rs = CurrentDb.OpenRecordset("select * from MYTABLE where
([MY_E-MAIL_FIELD] Is Not Null)")



Response = MsgBox("Start sending E-Mails via Outlook?", vbYesNo)

If Response = vbNo Then Exit Sub



Do Until rs.EOF

Set olItem = olApp.CreateItem(olMailItem)

olItem.To = rs("MY_E-MAIL_FIELD")

olItem.Subject = Me.MY_EMAILSUBJECT_FIELD

olItem.Body = Me.MY_EMAILBODY_FIELD



If Me.My_EMAILATTACHMENT_FIELD = "" Then

Else

evFile = Me.MY_EMAILATTACHMENT_FIELD



' Here, two invalid lines - Error message: Invalid file or path name

' evFile = Me.MY_EMAILATTACHMENT_FIELD & "; " &
Me.MY_EMAILATTACHMENT_FIELD2

' evFile = Me.MY_EMAILATTACHMENT_FIELD & " " &
Me.MY_EMAILATTACHMENT_FIELD2
' End of the not working part



olItem.Attachments.Add evFile

End If



If Me.MY_AUTOSEND_FIELD = -1 Then

olItem.Send

Set olItem = Nothing

Else

olItem.Display

Set olItem = Nothing

Response = MsgBox("Next email?", vbYesNo)

If Response = vbNo Then

rs.Close

Exit Sub

End If

End If



rs.MoveNext

Loop

rs.Close

Set rs = Nothing

Set olApp = Nothing



LABEL2:

Exit Sub



LABEL1:

MsgBox Err.Description

Resume LABEL2:



End Sub



Reply With Quote
Reply




Thread Tools
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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.