Re: trouble in sending email

alicejwz

Registered User.
Local time
Today, 18:10
Joined
Jul 9, 2003
Messages
91
Re: trouble in sending email

Hi all,

Why won’t Outlook sent from the code below? It opens to MS Outlook window and after clicking “yes” to send email. Sometimes it hangs. But when trying to open Outlook to check the email, it won’t open Outlook program and in Windows Task Manager you can see Outlook in Process. If you delet it the email is not sent.
But the strange thing is if I put a break in the code say “End With” and ran the subroutine it disappear in Windows Task Manager and the email is sent in Outlook.

Sub

Dim objOL As New Outlook.Application
Dim objMail As MailItem

Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)


With objMail

.To = "alicew@applerubber.com"
.Subject = "Test Message"
.Body = vbCrLf & vbCrLf & "Work Order Line # " & vbCrLf & 123456 & " " & "001" & ""
.Send

End With


Set objOL = Nothing
Set objMail = Nothing

End Sub

Thanks for your input!
 
I copied you code, put it behind a command button on a form and it worked just fine.

Outlook sent it and Thunderbird received it.


I use code that is similar to yours for testing email in access. (Not mine found it in a forum)

Code:
Private Function MyMail()
Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)

With outMsg      '.Importance = olImportanceHigh
.To = Me.EMailAddress
'.CC = "CC Mail address goes here"
'.BCC = " BCC Mail address goes here "'
.Subject = "Your subject goes here" '
.Body = "The body of your message goes here"
'.Attachments.Add "Your file path and name", , , "Your file names"
' If you want the screen to be seen then add the following line
.Display
'.Send
End With
Set outApp = Nothing
Set outMsg = Nothing
End Function
 
Re: Trouble in sending email

Thanks for testing it. Did you test it w/ vbCRLF in the body of the message?
I'm using AC2K, SQL Server 2K & Outlook 2K.
Thanks!
 
As I said:
I copied you code, put it behind a command button on a form and it worked just fine.

I just used copy and paste and never made any changes. The vbCrLf appears to work fine

I am using Access 2003 (2000 Format) Outlook 2003.


If you send me a PM with an e-mail address I will send from my Access to your E-Mail address and you can see the results for yourself.

Good luck.
 

Users who are viewing this thread

Back
Top Bottom