Really need help! Button to email

G

Guest

I know that everyone here volunteers their time, but could someone please
have a quick look at this post?

I have two buttons on my form (frmFirst). One to email the details entered on
the form to a set address(cmdCustomerCare) and another to email the details
to the email address jin a control on the form(cmdEmailResp). Now - I have
set them up exactly the same (gone through the properties of the control to
the OnClick event, written the code there) and the first one(cmdCustomerCare)
is working beautifully but the second one produces nothing. No email, no
flickers, no error message. Why? When they are practically the same? (posted
below)

Private Sub cmdCustomerCare_Click()
On Error GoTo Err_cmdCustomerCare_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg

Dim OlkRecip As Outlook.Recipient
Set OlkRecip = .Recipients.Add("(e-mail address removed)")

OlkRecip.Type = olTo
..Subject = "Customer Care Follow Up CRD" & Me![pkCRDNumber]
..Send

End With

Set Olk = Nothing
Set OlkMsg = Nothing
Set OlkRecip = Nothing

Exit_cmdCustomerCare_Click:
Exit Sub

Err_cmdCustomerCare_Click:
MsgBox Err.Description
Resume Exit_cmdCustomerCare_Click

End Sub

****************************

Private Sub cmdEmailResp_Click()
On Error GoTo Err_cmdEmailResp_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg
..To = "mailto:" & Me![RespPersonEmail]
..Subject = "Message - Query to follow up"
..Body = "Please follow up on " & Me![pkCRDNumber]
..Send
End With

Set Olk = Nothing
Set OlkMsg = Nothing

Exit_cmdEmailResp_Click:
Exit Sub

Err_cmdEmailResp_Click:
MsgBox Err.Description
Resume Exit_cmdEmailResp_Click

End Sub

*****************************
 
D

Douglas J Steele

Sorry, but you haven't set them up "exactly the same"

In the first sample, you're using:
With OlkMsg

Dim OlkRecip As Outlook.Recipient
Set OlkRecip = .Recipients.Add("(e-mail address removed)")

OlkRecip.Type = olTo

in the second, you're using
With OlkMsg
.To = "mailto:" & Me![RespPersonEmail]

Unfortunately, I don't use Outlook, so I can't help any further than that!
See whether Tony Toews has anything at
http://www.granite.ab.ca/access/email.htm that helps.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


albycindy said:
I know that everyone here volunteers their time, but could someone please
have a quick look at this post?

I have two buttons on my form (frmFirst). One to email the details entered on
the form to a set address(cmdCustomerCare) and another to email the details
to the email address jin a control on the form(cmdEmailResp). Now - I have
set them up exactly the same (gone through the properties of the control to
the OnClick event, written the code there) and the first one(cmdCustomerCare)
is working beautifully but the second one produces nothing. No email, no
flickers, no error message. Why? When they are practically the same? (posted
below)

Private Sub cmdCustomerCare_Click()
On Error GoTo Err_cmdCustomerCare_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg

Dim OlkRecip As Outlook.Recipient
Set OlkRecip = .Recipients.Add("(e-mail address removed)")

OlkRecip.Type = olTo
.Subject = "Customer Care Follow Up CRD" & Me![pkCRDNumber]
.Send

End With

Set Olk = Nothing
Set OlkMsg = Nothing
Set OlkRecip = Nothing

Exit_cmdCustomerCare_Click:
Exit Sub

Err_cmdCustomerCare_Click:
MsgBox Err.Description
Resume Exit_cmdCustomerCare_Click

End Sub

****************************

Private Sub cmdEmailResp_Click()
On Error GoTo Err_cmdEmailResp_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg
.To = "mailto:" & Me![RespPersonEmail]
.Subject = "Message - Query to follow up"
.Body = "Please follow up on " & Me![pkCRDNumber]
.Send
End With

Set Olk = Nothing
Set OlkMsg = Nothing

Exit_cmdEmailResp_Click:
Exit Sub

Err_cmdEmailResp_Click:
MsgBox Err.Description
Resume Exit_cmdEmailResp_Click

End Sub

*****************************
 
G

Guest

Thanks for the link!

Douglas J Steele said:
Sorry, but you haven't set them up "exactly the same"

In the first sample, you're using:
With OlkMsg

Dim OlkRecip As Outlook.Recipient
Set OlkRecip = .Recipients.Add("(e-mail address removed)")

OlkRecip.Type = olTo

in the second, you're using
With OlkMsg
.To = "mailto:" & Me![RespPersonEmail]

Unfortunately, I don't use Outlook, so I can't help any further than that!
See whether Tony Toews has anything at
http://www.granite.ab.ca/access/email.htm that helps.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


albycindy said:
I know that everyone here volunteers their time, but could someone please
have a quick look at this post?

I have two buttons on my form (frmFirst). One to email the details entered on
the form to a set address(cmdCustomerCare) and another to email the details
to the email address jin a control on the form(cmdEmailResp). Now - I have
set them up exactly the same (gone through the properties of the control to
the OnClick event, written the code there) and the first one(cmdCustomerCare)
is working beautifully but the second one produces nothing. No email, no
flickers, no error message. Why? When they are practically the same? (posted
below)

Private Sub cmdCustomerCare_Click()
On Error GoTo Err_cmdCustomerCare_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg

Dim OlkRecip As Outlook.Recipient
Set OlkRecip = .Recipients.Add("(e-mail address removed)")

OlkRecip.Type = olTo
.Subject = "Customer Care Follow Up CRD" & Me![pkCRDNumber]
.Send

End With

Set Olk = Nothing
Set OlkMsg = Nothing
Set OlkRecip = Nothing

Exit_cmdCustomerCare_Click:
Exit Sub

Err_cmdCustomerCare_Click:
MsgBox Err.Description
Resume Exit_cmdCustomerCare_Click

End Sub

****************************

Private Sub cmdEmailResp_Click()
On Error GoTo Err_cmdEmailResp_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg
.To = "mailto:" & Me![RespPersonEmail]
.Subject = "Message - Query to follow up"
.Body = "Please follow up on " & Me![pkCRDNumber]
.Send
End With

Set Olk = Nothing
Set OlkMsg = Nothing

Exit_cmdEmailResp_Click:
Exit Sub

Err_cmdEmailResp_Click:
MsgBox Err.Description
Resume Exit_cmdEmailResp_Click

End Sub

*****************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top