email function syntax error

S

shanebgross

I have a simple function to open an email with the recipient and subject
filled in. The function is pasted below. I want to set a button on a form
to use that function and fill in the recipient and subject. When I try to do
that on the on click event for the button I get an error: "Compile error :
Expected =" I must be missing something on the syntax on that line. Any
ideas?

Here's what's on the on click event for the button:
Private Sub Command6_Click()

mailaddress = "(e-mail address removed)"
subj = "this is subj"
SendMessage (mailaddress, subj)

End Sub

After typing the SendMessage line and hitting enter I get the error. Here's
what's in the function. If I take out the subject part and do it with only
the address, it works fine.

Function SendMessage(strto, strsubj)

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
.To = strto
.subject = strsubj
.Display

End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Function
 
S

shanebgross

Droppdng the parentheses fixed it--I figured it must be something simple.

Thanks!
 

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