Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel attachments - vba job

Status
Not open for further replies.

eHanSolo

Technical User
May 24, 2004
260
GB
hi all,

i'm looking to automate sending out a few emails from excel using vba. I have most of the code for this already.

my problem is that, how to get what i want (in this case, just a range of cells data) in the body of the email object.

any suggestions/recommendations is highly welcome!!

thanks!!

e
 
This is the closest that I could come:

Code:
Public Sub OutlookMail()
Dim strLine As String

    Dim i As Long
    
    Set myOlApp = CreateObject("Outlook.Application")
    Set myitem = myOlApp.CreateItem(olMailItem)
    
    For i = 0 To Rows.Count - 1
        If ActiveCell.Offset(i, 0).Value = "" Then Exit For
        strLine = strLine & vbNewLine & ActiveCell.Offset(i, 0).Value
        myitem.Body = strLine
       
        
    Next
        
    myitem.Subject = "File"

        
    myitem.Display

End Sub

I hope this helps.

PS: I set a reference to the Outlook library. If you find a better way, please post. I'm always looking for new ways to automate Outlook.

Ron Repp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top