Sending emails

JohnLee

Registered User.
Local time
Today, 08:04
Joined
Mar 8, 2007
Messages
692
Hi,

I want to send an email to different individuals and the body content is different for each individual, I'm getting a problem with the second part of my code:

Code:
Dim olApp As Outlook.Application                    'Declare the outlook application variable
Dim olMail As MailItem                              'Declare the Mail Item variable
Set olApp = New Outlook.Application                 'Set the olApp to a new outlook application
Set olMail = olApp.CreateItem(olMailItem)           'Set the olMail to create an outlook mail item
 

    With olMail                                                                                                 'Create and sends the email
        .To = "[EMAIL="Matthew.Ashcroft@domesticandgeneral.com"]Matthew.Ashcroft@domesticandgeneral.com[/EMAIL]"                                                         'Address the email to [EMAIL="Matthew.Ashcroft@domesticandgeneral.com"]Matthew.Ashcroft@domesticandgeneral.com[/EMAIL]
        .CC = "[EMAIL="Olga.potaptseva@domesticandgeneral.com"]Olga.potaptseva@domesticandgeneral.com[/EMAIL]"                                                          'Copy the email to [EMAIL="Olga.Potaptseva@domestigandgeneral.com"]Olga.Potaptseva@domestigandgeneral.com[/EMAIL]
        .BCC = "[EMAIL="elaine.boulton@domesticandgeneral.com"]elaine.boulton@domesticandgeneral.com[/EMAIL]"                                                          'Copy the email to [EMAIL="elaine.boulton@domesticandgeneral.com"]elaine.boulton@domesticandgeneral.com[/EMAIL]
        .Subject = "Marketing - Monthly Scanned Volumes Report"                                                 'Provide the subject matter for the email
        .Body = "Good Day," & vbCrLf & vbCrLf & "The Monthly Volumes Report is now available in the \Marketing\ScanMthVols Folder." & vbCrLf & _
                "This file is in snapshot format, if you don't have snapshot the snpvw.exe file it is located in the Questionniars drive. " & vbCrLf & _
                "Copy it to your PC and double click on the snpvw.exe to install it, then you will be able to open it" & vbCrLf & vbCrLf & vbCrLf & _
                "Scanning Operations" & vbCrLf & _
                "Domestic & General"                                                                                                                        'Provide the text body for the email
        .Send                                                                                                                                               'Send the email
    End With
    
    With olMail
        .To = "[EMAIL="Hari.Govindan@domesticandgeneral.com"]Hari.Govindan@domesticandgeneral.com[/EMAIL]"                                                            'Address email to [EMAIL="Hari.Govindan@domesticandgeneral.com"]Hari.Govindan@domesticandgeneral.com[/EMAIL]
        .CC = "[EMAIL="Karen.Page@domesticandgeneral.com"]Karen.Page@domesticandgeneral.com[/EMAIL]"                                                               'Copy the email to [EMAIL="Karen.Page@domesticandgeneral.com"]Karen.Page@domesticandgeneral.com[/EMAIL]
        .BCC = "[EMAIL="elaine.boulton@domesticandgeneral.com"]elaine.boulton@domesticandgeneral.com[/EMAIL]"                                                          'Copy the email to [EMAIL="elaine.boulton@domesticandgeneral.com"]elaine.boulton@domesticandgeneral.com[/EMAIL]
        .Subject = "Service - Monthly Scanned Volumes Report"                                                   'Provide the subject matter for the email
        .Body = "Good Day," & vbCrLf & vbCrLf & "The Monthly Volumes Report is now available in the \Customer Satisfaction\ScanMthVols Folder." & vbCrLf & _
                "This file is in snapshot format, if you don't have snapshot the snpvw.exe file it is located in the Questionniars drive. " & vbCrLf & _
                "Copy it to your PC and double click on the snpvw.exe to install it, then you will be able to open it" & vbCrLf & vbCrLf & vbCrLf & _
                "Scanning Operations" & vbCrLf & _
                "Domestic & General"                                                                                                                        'Provide the text body for the email
        .Send
    End With

The code errors out at the second instance of sending an email ".To = "Hari.Govindan@domesticandgeneral.com" "

Is it not possible to send emails in this way within access or is there another way to do this.

Any Assistance wouldbe most appreciated.

Regards

John
 
Hi,

I didn't think of that, I'll give that a go thanks

Regards

John
 
Hi pr2_eugin,

Thanks for the pointer, problem resolved.

regards

John
 
You are welcome John, I am not an expert.. but an object can only send one instance of email.. You can send email with the same object by setting it to nothing after you have used it first, and then again reassigning to a new instance of email.. but as I said I might be wrong..
 

Users who are viewing this thread

Back
Top Bottom