Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Does anyone know the command to send via VBA?

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Where the wild roses grow
    Posts
    285
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  2. #2
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Where the wild roses grow
    Posts
    285
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    That doesnt work, it says "Invalid or unqualified reference"

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Where the wild roses grow
    Posts
    285
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    It's cool, I had it in the wrong place

    Thanks Ivan

  5. #5
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •