1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Excel VBA code to email as attachment

Discussion in 'Business Applications' started by KainAussie, Jun 17, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. KainAussie

    KainAussie Thread Starter

    Joined:
    Jun 17, 2012
    Messages:
    9
    Hi,

    could some one please help me here is what i have

    i have a excel spreadsheet with data and formulas in it for a quote for a mates pc business he wants me to make him a template
    and he needs the code so when he runs the code it comes up with a input box asking for the users email to send it to and all of the emails with the subject "Quote"
    can some one please help me?
     
  2. Keebellah

    Keebellah Hans Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    5,957
    Here's some code I gave other postyers with similar questions.

    Code:
    Option Explicit
    
    Function MailData(mSubject As String, mMessage As String, Sendto As String, Optional CCto As String)
    Dim eSubject As String, Sendto As String, CCto As String, EBody As String
    Dim app As Object, Itm As Variant
    Set app = CreateObject("Outlook.Application")
    Set Itm = app.CreateItem(0)
    
    With Itm
        .Subject = mSubject
        .To = Sendto
        If Not IsMissing(CCto) Then .CC = CCto
        .Body = mMessage
    '     .Attachments.Add (NewFileName1) ' Must be complete path
        .Display ' This property is used when you want
    '    .send
    End With
    Set app = Nothing
    Set Itm = Nothing
    End Function
    
    You will need to write the macro that passes the data to it'.

    With some trial and error you'll probably work it out.

    I can advice the link below to find almost everything you may need regarding VBA and it includes many (ex)/(s)amples

    http://www.rondebruin.nl/tips.htm

    If you get stuck just holler :)
     
  3. KainAussie

    KainAussie Thread Starter

    Joined:
    Jun 17, 2012
    Messages:
    9
    if i put that code in a command button it will work?
    i no nothing about VBA
    if not can you tell me what i need to add?
     
  4. Keebellah

    Keebellah Hans Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    5,957
    I need to knwo what you have.
    Guessing isn't one of my stongest abilities :)

    I would need more info and a sample. The code I passed you won't do anything on it's own and a lack of VBA knowledge won't make it easier, but if you post a sample of your file with let's say 5 dummy records and tell me exactly what you want / expect to do I'will gladly try my best.
    No promises but who knows.
     
  5. KainAussie

    KainAussie Thread Starter

    Joined:
    Jun 17, 2012
    Messages:
    9
    its all good i solved it found a way online
     
  6. Keebellah

    Keebellah Hans Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    5,957
    Good :), don't forget to press the 'Marked Solved" button to close the post
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1057437