E mail problem

monplankton

Registered User.
Local time
Today, 06:11
Joined
Sep 14, 2011
Messages
83
Been using a mailing program for some time to send out 2 documents using a mailing list in Access 2003 but for some reason, beyond me it has thrown up an error, any help much appricated.

Code:
Private Sub Command12_Click()
Do
Dim objOutlook As Outlook.Application, objMailItem As MailItem
  Set objOutlook = New Outlook.Application
  Set objMailItem = objOutlook.CreateItem(olMailItem)
With objMailItem
    .To = Me![E'Mail]
    .Subject = "Inspection updates"
    .Body = "Please refer to the attachments regarding changes and updates to the inspection operational procedures, effective from 01/04/2012. Please circulate to all relevant personnel."
    .Attachments.Add "D:\Inspection Presentation (FY12).pdf"
    .Attachments.Add "D:\2012 Supplier update letter.pdf"
    .Send
 End With
 
 
  Set objMailItem = Nothing
Set objOutlook = Nothing
     
        DoCmd.GoToRecord , , acNext
    Loop
    
End Sub
 
You diden't say where and what the error was, but since this worked before the I might venture to guess that the Office enviroment has changed and you are refrencing the wrong Outlook liberary.

You are using Early-binding so switch to Late-binding might help.

try this:

Code:
Private Sub Command12_Click()
[COLOR="Red"]Const olMailItem = 0[/COLOR]

Do
Dim objOutlook As [COLOR="red"]Object[/COLOR], objMailItem As [COLOR="red"]Object[/COLOR]
  
Set objOutlook = [COLOR="red"]CreateObject("Outlook.Application")[/COLOR]
Set objMailItem = objOutlook.CreateItem(olMailItem)

With objMailItem
    .To = Me![E'Mail]
    .Subject = "Inspection updates"
    .Body = "Please refer to the attachments regarding changes and updates to the inspection operational procedures, effective from 01/04/2012. Please circulate to all relevant personnel."
    .Attachments.Add "D:\Inspection Presentation (FY12).pdf"
    .Attachments.Add "D:\2012 Supplier update letter.pdf"
    .Send
 End With
 
 
  Set objMailItem = Nothing
  Set objOutlook = Nothing
     
        DoCmd.GoToRecord , , acNext
Loop
    
End Sub

the changes are in red

JR
 
JR Thanks for the help but for what ever reason it just started working. Wierd!
 

Users who are viewing this thread

Back
Top Bottom