run-time error '462' the remote server machine does not exist or is unavailable.

amos madanes 1 Reputation point

I am trying to email a screenshot of userForm with outlook. The spreadsheet is saved in our company google drive and works without a hitch in a couple of computers, but in most It stops with the above error.

The code for the email function is:

Function outlookEmail()
Dim doc As Object

Dim OutApp As Outlook.Application 'this is an outlook object
Dim oOutlookEmail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set oOutlookEmail = OutApp.CreateItem(0)

On Error Resume Next
Set OutApp = GetObject(, "Outlook.Application")
If Err.Number > 0 Then Set OutApp = CreateObject("Outlook.Application")
On Error GoTo 0

Application.SendKeys "(%{1068})"

With oOutlookEmail
    Set doc = .GetInspector.WordEditor
    doc.Range(0, 0).Paste
    .To = sDetail.Cells(myRow, headerDict.item("email"))
    .Subject = "documents for you"
     Application.Wait (Now + TimeValue("0:00:01"))
     Application.SendKeys "%s"
End With

End Function

the error usually occurs in the set doc line.

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,583 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
4,947 questions
0 comments No comments
{count} votes