Community discussion forum

one button email to:

Tags: vba Malaysia
  • 7 months ago

    hey guys... need your help

    im using ms excel for a simple time stamp (attandance) thingy. i want to have a button where OnClick event it will automatically send the file as attachment via outlook email.

    any macro scipts

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 7 months ago

    Hi

    Add a reference to Microsoft Excel.

    Try the following.

    Sheets("Sheet1").Select
     
    dname = Range("B1").Value 'defines data for subject

    Dim objol As New Outlook.Application
    Dim objmail As MailItem
    Set objol = New Outlook.Application
    Set objmail = objol.createitem(olmailitem)
       With objmail
           .To = "whoever" 'enter in here the email address
           .cc = "whoever" 'enter in here the email address
           .Subject = "Daily test email for  " & dname
           .Body = "Please find attached the teste email" & _
               vbCrLf & "If you have any queries can you please let me know" & vbCrLf
           .NoAging = True
           .Attachments.Add ThisWorkbook.FullName 'adds attachment to email
           .display
       End With
       Set objmail = Nothing
       Set objol = Nothing
       SendKeys "%{s}", True 'send the email without prompts

  • 7 months ago

    hey thanks for the reply.

    but i have a problem. how do i set the code in the macro? coz it says user defined type is not identified

     [quote user="Jugatsu"]Dim objol As New Outlook.Application[/quote]

    please guide in detail.

    thanks in advace

  • 7 months ago

    Click Tools
     - References
     - Tick Microsoft Outlook 10.0 Object Library
       ( or similar, outlook needs to be installed)

Post a reply

Enter your message below

Sign in or Join us (it's free).