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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hey, If i have the code below. 1

Status
Not open for further replies.

SQLScholar

Programmer
Aug 21, 2002
2,127
GB
Hey,

If i have the code below.

Code:
Public Function SendEmail(Optional msgCC As String, Optional msgSubject As String, Optional msgBody As String, Optional ImportanceHigh As Boolean = False, Optional SendNow As Boolean = False)
    
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.Attachment
        Set objOutlook = CreateObject("Outlook.Application")
        Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
        With objOutlookMsg
            .To = "me@here.com"
            .Subject = "this"
            .Body = "Type Problem/Query/Comment here"
            .Importance = olImportanceHigh
            .Display (True)
        End With
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
End Function

and i want the subject to be a combination of a cell and the file name of the running excel file.

How do i do this??

TIA

Dan ----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
mysubject = activecell.value + " from " + activeworkbook.name

and then replace:

.Subject = "this"

with:

.Subject = mysubject

You will probably want to improve on that a bit.

left(activeworkbook.name,len(activeworkbook.name) -4)
takes the .xls off the filename




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top