Opening new email from command button
Results 1 to 6 of 6

Thread: Opening new email from command button

  1. #1
    New Member
    Join Date
    Aug 2019
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Opening new email from command button

    I am creating a userform that my sales people will use to generate a Purchase Order Request. The form will populate a spreadsheet that my inventory control department can use to track the status of requests. I want the "save" button that saves the userform and populates the data to the spreadhseet to also open a new email (we all use outlook). The email would be from them to our Orders email inbox. This will allow them to attach a file like a quote or a spec sheet to the email.

    I'd like the email to have the subject line "PO Request for *" Where * is the value of an ID number Generated by the table in the spreadsheet.

  2. #2
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    5,731
    Post Thanks / Like
    Mentioned
    65 Post(s)
    Tagged
    14 Thread(s)

    Default Re: Opening new email from command button

    Welcome to the forum.

    You need something like this:

    Code:
    Sub email_test()
      Dim dam As Object
      ActiveSheet.Copy
      ActiveWorkbook.SaveAs ThisWorkbook.Path & "\PO.xlsx"
      ActiveWorkbook.Close
      Set dam = CreateObject("Outlook.Application").CreateItem(0)
      dam.To = "email@gmail.com"              'recipients
      dam.Subject = "PO Request for " & Range("E2").Value         'Subject
      dam.Body = "body"
      dam.Attachments.Add ThisWorkbook.Path & "\PO.xlsx"   'file
      dam.Display                             ' Change Send to send email
    End Sub
    Regards Dante Amor

  3. #3
    New Member
    Join Date
    Aug 2019
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Opening new email from command button

    Is it possible to change "Outlook.Application" to something like "DefaultEmail.Application" to open up whatever default email program is they are using?

  4. #4
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    5,731
    Post Thanks / Like
    Mentioned
    65 Post(s)
    Tagged
    14 Thread(s)

    Default Re: Opening new email from command button

    Quote Originally Posted by poetrysue View Post
    Is it possible to change "Outlook.Application" to something like "DefaultEmail.Application" to open up whatever default email program is they are using?

    did you try the macro?

    I put outlook for this:

    "we all use outlook"
    Regards Dante Amor

  5. #5
    New Member
    Join Date
    Aug 2019
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Opening new email from command button

    Yes and it works great! And yes we do all use outlook, but the boss wants it to be a little more flexible in case someone is accessing it from a computer that is not their work computer and needs to use a different email client.

  6. #6
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    5,731
    Post Thanks / Like
    Mentioned
    65 Post(s)
    Tagged
    14 Thread(s)

    Default Re: Opening new email from command button

    I don't know the instruction to have that flexibility.
    You could create a new thread, to see if they answer that question.


    Meanwhile, it was a pleasure helping you. Good luck
    Regards Dante Amor

Some videos you may like

User Tag List

Tags for this Thread

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
  •