crossblade
New Member
- Joined
- May 19, 2015
- Messages
- 9
Hi everyone,
I had a requirement to send an attachment via outlook which I have included the code I am using for that below. What I now need to do is enable me to send the same via Lotus Notes if that is what the user uses. Also is there a good way to detect which mail system the user is using, then I could call different routines as appropriate.
Sub RenameThenSaveFile()
ChDir "C:\Users\Public"
ActiveWorkbook.SaveAs Filename:="C:\Users\Public\" & FileNameString & ".xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
MailWorkbookUsingOutlook
Range("A2").Select
End Sub
Sub MailWorkbookUsingOutlook()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "fred@fred.com" 'AddressToSendEmailTo
.CC = ""
.BCC = ""
.Subject = FileNameString
.Body = FileNameString
.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Thanks for looking.
I had a requirement to send an attachment via outlook which I have included the code I am using for that below. What I now need to do is enable me to send the same via Lotus Notes if that is what the user uses. Also is there a good way to detect which mail system the user is using, then I could call different routines as appropriate.
Sub RenameThenSaveFile()
ChDir "C:\Users\Public"
ActiveWorkbook.SaveAs Filename:="C:\Users\Public\" & FileNameString & ".xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
MailWorkbookUsingOutlook
Range("A2").Select
End Sub
Sub MailWorkbookUsingOutlook()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "fred@fred.com" 'AddressToSendEmailTo
.CC = ""
.BCC = ""
.Subject = FileNameString
.Body = FileNameString
.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Thanks for looking.