Send mail via Outlook

  • Thread starter Thread starter Phil Hellmuth
  • Start date Start date
P

Phil Hellmuth

I've written vba code to send mail via Outlook, but when running the
code, the code interrupts to prompt the user to choose an Outlook
profile. Is there a way to bypass this prompt, and go with the default
profile?

Thanks in advance.
 
yes there is, but you might need to paste in the code you use because there
is more than 1 way to use outlook and it depend on how you have done it.
 
OK, here's the code....

Public Sub SendMail(strSubject As String, strMsg As String)

Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem

Set MyOutlook = New Outlook.Application
Set MyMail = MyOutlook.CreateItem(olMailItem)


MyMail.To = "(e-mail address removed)"
MyMail.Subject = strSubject
MyMail.Body = strMsg
MyMail.Send

set MyOutlook = Nothing
set MyMail = 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

Back
Top