Does anyone know the command to send via VBA?

Audiojoe

Active Member
Joined
Feb 20, 2002
Messages
285
I have the below code in a module that sets up an email, but I can't remember the code that sends it automatically. Does anyone know?

Sub OUTLOOK_collections_email()

'creates link to Outlook
Dim objOL As New Outlook.Application
Dim objMail As MailItem

On Error Resume Next

Set objOL = New Outlook.Application
Set testsemail = objOL.createitem(olmailitem)

'sets characteristics for email
With testsemail
.ReadReciptRequested = False
.To = "mail@mail.com"
.Subject = "Subject"
.Display
.Body = "Blah Blah Blah"
End With

End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
On 2002-03-18 01:50, Audiojoe wrote:
I have the below code in a module that sets up an email, but I can't remember the code that sends it automatically. Does anyone know?

Sub OUTLOOK_collections_email()

'creates link to Outlook
Dim objOL As New Outlook.Application
Dim objMail As MailItem

On Error Resume Next

Set objOL = New Outlook.Application
Set testsemail = objOL.createitem(olmailitem)

'sets characteristics for email
With testsemail
.ReadReciptRequested = False
.To = "mail@mail.com"
.Subject = "Subject"
.Display
.Body = "Blah Blah Blah"
End With

End Sub

Just add
.Send

between the With and End with statements
where you reference the testsemail


Ivan
 
Upvote 0
On 2002-03-18 02:11, Audiojoe wrote:
That doesnt work, it says "Invalid or unqualified reference"

This worked for me ??!!

Sub OUTLOOK_collections_email()

'creates link to Outlook
Dim objOL As New Outlook.Application
Dim objMail As MailItem

Dim testsemail

On Error Resume Next

Set objOL = New Outlook.Application
Set testsemail = objOL.createitem(olmailitem)

'sets characteristics for email
With testsemail
.ReadReciptRequested = False
.To = "mail@mail.com"
.Subject = "Subject"
.Display
.Body = "Blah Blah Blah"
.Send
End With

End Sub


Ivan
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,688
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top