E-Mailing

louiserome

Registered User.
Local time
Today, 10:09
Joined
May 22, 2001
Messages
14
I am currently trying to send multiple e-mails from an Access2000 database via Outlook2000. I can get the outlook message up with all the names in the correct place but my problem is that it takes about 10 seconds to check the addresses and underline them before I can can send the message, before this I get an error message. This becomes a problem if I want the e-mail to go without editing it. It keeps saing that it wants to check the names. I have even turned off this option in Outlook and it is still throwing up an error. Has anyone had this problem before?
 
Hi There,
Are you sure it is opening the E-Mail up in Outlook and not Outlook Express. Quite often the default E-Mail client is Outlook Express. I am not sure how to get Outlook to be the default. Hopefully someone else will know how.

Pob
 
Private Sub lblgo_Click()
Me.Refresh
[Date_Created] = Now()
[UserName] = CurrentUser()
On Error GoTo EMail_Err

Dim db As Database
Dim rsMySet As Recordset
Dim MyMail As Recordset
Dim a As Integer
Dim b
Dim c As Integer
Dim d
Dim e As Integer
Dim f
Dim g As Integer
Dim h
Dim strSQL As String
Dim MyString As String
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' Set up the recordset from the table
Set db = CurrentDb()
Set rsMySet = db.OpenRecordset("SELECT [E-Mail].* FROM [E-Mail] WHERE [Mail_ID] =" & Forms!frmProgram!Mail_ID)
Set MyMail = db.OpenRecordset("SELECT [qryMail_attach].[E-Mail] FROM qryMail_attach WHERE [Mail_ID] =" & Forms!frmProgram!Mail_ID)
' Create the Outlook session.
Set objOutlook = CreateObject("outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.

MyString = MyMail("E-Mail")
If IsNull(MyString) Then
Else:
MyMail.MoveNext
Do
MyString = MyString & ";" & MyMail("E-Mail")
MyMail.MoveNext
Loop Until MyMail.EOF
Set objOutlookRecip = .Recipients.Add(MyString)
objOutlookRecip.Type = olTo
MyMail.Close
End If

' Add the CC recipient(s) to the message.
For c = 1 To 10
d = rsMySet("cc" & c)
If IsNull(d) Then
Else:
Set objOutlookRecip = .Recipients.Add(d)
objOutlookRecip.Type = olCC
End If
Next c

' Add the BCC recipient(s) to the message.
For e = 1 To 10
f = rsMySet("bcc" & e)
If IsNull(f) Then
Else:
Set objOutlookRecip = .Recipients.Add(f)
objOutlookRecip.Type = olBCC
End If
Next e

' Set the Subject, Body, and Importance of the message.
.Subject = rsMySet("Subject")
.Body = rsMySet("Body") & vbCrLf & vbCrLf

' Add attachment(s) to the message.
For g = 1 To 5
h = rsMySet("Attachment" & g)
If IsNull(h) Then
Else:
.Attachments.Add (h)
End If
Next g


' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If rsMySet("message") = True Then
.Display
Else
.Save
.Send
End If
End With

rsMySet.Close

EMail_Exit:
Set objOutlook = Nothing
Set rsMySet = Nothing
Set db = Nothing
Exit Sub

EMail_Err:
Select Case Err
Case Else
MsgBox "Unexpected Error# " & Err & " - " & Error$(Err), vbCritical, "Lou - EMail routine"
Resume EMail_Exit
End Select
End Sub
 
Hi Louise,

i've had a look and at the end of a long day all those IFs without statements are confusing me ( did you know you can use "If Not Isnull(Whatever) Then ..."? saves extra typing
smile.gif
). Here's the code i use to mail stuff out - you need to build your recipient mail string and send it in as an argument, but that makes it more flexible. I've used it to send mail to 150 people at one time, but as you say it still gets an error on sending if there are ambiguous names. This has only occured for me on internal emails to people named things like Smith, John - outlook likes to check that you don't mean "Smith, John x" etc etc. I don't think you can get round it - that's why i alway display messages before sending.

Code:
Public Function xMailOut(strBody as String, strTitle As String, strTo As String, blnDisplay As Boolean, _
 Optional strAttach As String, Optional strAttach2 As String, Optional strAttach3 As String)
'Code written By Drew
'#################################################################################
'############## This generates the mail with the completed file attached #########
'#################################################################################
Dim oOutlook As New Outlook.Application
Dim oMessage As Outlook.MailItem
    
    
     Set oMessage = oOutlook.CreateItem(olMailItem)

    With oMessage
        .To = strTo
        .Subject = strTitle
        .Body = strBody
    End With
    
    If StrComp(strAttach1, "") <> 0 Then
        With oMessage
            .Attachments.Add strAttach1
        End With
    End If
    
    If StrComp(strAttach2, "") <> 0 Then
        With oMessage
            .Attachments.Add strAttach2
        End With
    End If
    
    If StrComp(strAttach3, "") <> 0 Then
        With oMessage
            .Attachments.Add strAttach3
        End With
    End If
    If blnDisplay Then
        oMessage.Display
    Else
        oMessage.Send
    End If
    Set oMessage = Nothing
    Set oOutlook = Nothing
End Function

like i say it won't solve the problem but displaying and clicking send is probably the only real way around it, think you need M$ for a real fix

HTH

Drew

[This message has been edited by KDg (edited 08-03-2001).]

[This message has been edited by KDg (edited 08-03-2001).]
 

Users who are viewing this thread

Back
Top Bottom