Runtime error 462 help

S

Song

Access 2007 and reference Microsoft Outlook 12.0 object library

First time run, it's OK. On the 2nd time run, it gives "runtime error
462. The remote server machine does not exist or is unavailable."

http://support.microsoft.com/kb/319832 talks about unqualified
reference but I don't know how to fix my code.

Also, I need 2 line gap between 'dear' line and table below it but
don't know how to do it.

Thank you for helping.

Song

Private Sub cmdEmail_Click()
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Dim ctlBody As String
Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
ctlBody = "Dear " & StrConv(Forms!Contacts.EmailTo, vbProperCase)
& ","
ctlBody = ctlBody & "<table border='1' width='90%'
bgcolor='#ECECEC'><tr><td width='119'>" & _
"Asset ID</td><td>" & _
Me.AID & "</td></tr><tr>" & _
"Item</td><td>" & _
UCase(Me.Item) & "</td></tr><tr>" & _
"Checkout on</td><td>" & _
Me.CheckOut & "</td></tr></table>"
With objMail
.To = StrConv(Forms!Contacts.First & " " & Forms!Contacts.Last,
vbProperCase) & _
"<" & IIf(IsNull(Forms!Contacts![E-mailUpdate]), Forms!Contacts!
EmailAddress, Forms!Contacts![E-mailUpdate]) & ">"
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>" & ctlBody & "</p></BODY></HTML>"
.Display
End With

Set objMail = Nothing
Set olApp = Nothing
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