+ Reply to Thread
Results 1 to 7 of 7

Mail from Excel - With attachment

  1. #1
    Registered User
    Join Date
    08-16-2010
    Location
    INDIA
    MS-Off Ver
    EXCEL 2010
    Posts
    53

    Mail from Excel - With attachment

    Hi I want to send mail from excel . for which below code works fine. am looking to midify this to ..
    1] I want to copy data from excel & paste in Lotus Body
    2} I want to send mail with attachment.

    Private Sub CommandButton1_Click()
    Dim s As Object
    Dim db As Object
    Dim doc As Object
    Dim nSession
    Set us1 = Range("g6:i24")
    Set s = CreateObject("Notes.NotesSession")
    Set db = s.GetDatabase(" ", "mail\username.nsf")
    Set doc = db.createdocument()
    doc.form = "Memo"
    doc.sendTo = "noname@noname.com"
    doc.Subject = " Sending Mail from EXCEL MACRO"
    doc.body = us1 '" Hi Pranali Sending Mail from EXCEL MACRO"
    Call doc.Send(False)
    Set nSession = Nothing

    End Sub

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Mail from Excel - With attachment

    See if this can help you with an attachment?

    Please Login or Register  to view this content.
    Does us1 take care of your first request?

  3. #3
    Registered User
    Join Date
    08-16-2010
    Location
    INDIA
    MS-Off Ver
    EXCEL 2010
    Posts
    53

    Re: Mail from Excel - With attachment

    1] us1 doesn't work it sent a blank mail w/o excel pasting.
    2] code given by you also sends blank mail w/o attachment.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Mail from Excel - With attachment

    Did you change the Path in the example I provided? The Path should be to the file which is to be attached. I though you had tested US1. I can help you with a couple of cells, but I can't with a range of cells as you indicated. Example doc.Body = Range("G6").Text & " " & Range("H6").Text will give the data in those two ranges.

  5. #5
    Registered User
    Join Date
    08-16-2010
    Location
    INDIA
    MS-Off Ver
    EXCEL 2010
    Posts
    53

    Re: Mail from Excel - With attachment

    Yes I have change path still it sends a blank mail. refer code below.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Mail from Excel - With attachment

    This line was used as a sample if you do not have data there, then there will be no results.

    doc.body = Range("G6").Text & " " & Range("H6")

    Also Range("H6") should be Range("H6").Text

    Try changing this line:

    Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment1")

    To this:

    Set AttachME = doc.CREATERICHTEXTITEM("Attachment1")

  7. #7
    Registered User
    Join Date
    08-16-2010
    Location
    INDIA
    MS-Off Ver
    EXCEL 2010
    Posts
    53

    Re: Mail from Excel - With attachment

    I hv got it solved for sending attachment , but pending for pasting excel content

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1