send email macro not working completely.....
Hello
I have a macro that does lots of things with multiple spreadsheets. The wokbook in which the macro is running is not actually used for anything as it is only a template. I have a sheet within the spreadsheet called users and I want to email the user should the UserName function match. I have a function already to give me the username logged into the LAN, I just dont know how to select the workbook where the users sheet is and then ask it to match the username with that in column A and if found send an email to the email address in column b. I hope this makes sense, Here is what I have so far, Private Sub MailMessage() Dim OutApp As Object Dim OutMail As Object Dim strbody As String Dim emailmanager As String Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "This has been created by: " & UserName If UserName = Range("A1:A100") Then Cells.Select End If With OutMail .To = .CC = "" .BCC = "" .Subject = Sheets("Summary").Range("D6").Value & " - Prelim" .Body = strbody .DeleteAfterSubmit = True .Display End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub It just keeps failing on me. I appreciate your help, Andrea |
All times are GMT +1. The time now is 12:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com