×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

MS Access 2013 Sneding Email using Outlook - multiple addressees and multiple attachments

MS Access 2013 Sneding Email using Outlook - multiple addressees and multiple attachments

MS Access 2013 Sneding Email using Outlook - multiple addressees and multiple attachments

(OP)
I have been using send object to send email from my DB but I can only send one attachment at a time. I need to send more. I have found some articles about using Outlook coding in VB to do the job because it can handle more attachments.

Question: On the VB screen, in Access, on the tools menu - references what do I select to enable me to use the Outlook code?

Question: Can someone show me some code to send email to multiple people (just 2 for demo) using 2 attachment files that are stored in a folder outside of access.

I believe, in the code, there is also a command to show the email before it is sent. I think I saw it one time and I think it actually used the word Show

Any help and/or references to a complete dissertation on how to do this would be appreciated.

I am currently trying to send 2 and 3 attachments depending on selection and I don't want my users to have to add addresses 2 or 3 times.

OH, also, I might be able to select the To: addresses from the DB. Right now I don't have the email addresses to all the necessary people in the DB.

Thanks,

John

RE: MS Access 2013 Sneding Email using Outlook - multiple addressees and multiple attachments

Did you try this approach?
One of the places that looks promising


---- Andy

There is a great need for a sarcasm font.

RE: MS Access 2013 Sneding Email using Outlook - multiple addressees and multiple attachments

I use the below... Note the constant SMTP server to specify and default from address in parameters.

This assumes your internal SMTP server is open (allows relaying) from traffic on the LAN.

CODE

Public Sub SendEmailCDO(strTo As Variant, strCC As Variant, strSubject As Variant, strBody As Variant, Optional strAttachment As String = "", Optional strFrom As String = "SomeOne@example.com")
    
    'Send e-mail with CDO.  Avoid Outlook trust issues.  Can specify From or reply address instead of a no reply address.
    'Requires Reference to "Microsoft CDO for Windows 2000 Library" If not using late Binding... Converted  to use late binding
        
    Dim cdoMessage As Object 'CDO.Message
    Dim cdoConfig  As Object 'CDO.Configuration
    Dim strFiles() As String
    Dim lngFileCount As Long
    Dim i As Long
    
    Const conSMPTServer = "smtp@example.com"
    
    Set cdoMessage = CreateObject("CDO.Message")
    Set cdoConfig = CreateObject("CDO.Configuration")
    
    
    
    'cdoConfig.Fields(cdoSendUsingMethod).Value = cdoSendUsingPort
    cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing").Value = 2 'cdoSendUsingPort
    
    'cdoConfig.Fields(cdoSMTPServer).Value = conSMPTServer
    cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value = conSMPTServer
    
    'cdoConfig.Fields(cdoSMTPServerPort).Value = 25
    cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport").Value = 25
    
    cdoConfig.Fields.Update
    
    Set cdoMessage.Configuration = cdoConfig
    
    With cdoMessage
        .To = strTo
        .From = strFrom
        .Subject = strSubject
        .CC = strCC
        '.TextBody = "This is the body of the first plain text email with CDO."
        .HTMLBody = strBody
        
        If strAttachment <> "" Then
          strFiles = Split(strAttachment, ",")
          lngFileCount = UBound(strFiles)
          For i = 0 To lngFileCount Step 1
            .AddAttachment (Trim(strFiles(i)))
          Next i
        End If
        
        .Send
    End With
    
    Set cdoConfig = Nothing
    Set cdoMessage = Nothing
    
End Sub 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close