Excel VBA to Attach File And Automatically Send Email
Forward mails with attachment in excel VBA code
Quote:
Originally Posted by
Friel300
E-Mailing from excel
hey this is a piece from my refereence file
it should work pretty well.
it should all be pretty straight forward to taylor to your needs.
Code:
Sub Mail_small_Text_Outlook()
'Working in Office 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Hi there" & vbNewLine & vbNewLine & _
"Cell A1 is changed" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
On Error Resume Next
With OutMail
.To = Email@Domain.com 'Email Address (can be a cell reference)
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = strbody
'.Attachments.Add ("C:\test.txt") 'You can add a file like this
.Display 'or use .Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
any problems give me a shout =D
This is quite good but what i need is to forward all mails saved in a folder to a different recipient with the attachments on the mails.I find it difficult to do and the above solution did not serve the purpose as attachments are sent from the hard drive location and not from the saved mails. Please help me to forward all mails in a saved folder with attachments if any.
Forward outlook mails with excel VBA
Hi,
Thank you for the reply...but let me expand the question for your better understanding.
I have copied some mails from outlook inbox to a folder. Some mails are with attachments and some are without. I need to automate it with excel vba to forward those mails to an email ID that i provide in one cell of excel sheet. I need to forward the mails to keep the format and attachments unchanged. Please help me to solve the problem as it's a project I am doing and having problem solving it on time.
Regards,
Malay
Forward outlook mails with excel VBA
Hi,
Thank you so much, but sorry to say this solution did not solve my purpose. I need to open each saved ".msg" file and forward it to a certain mail address, reason i want to forward it to keep the mail format and attachment unchanged.
I can read the mail and then take the body content to another mail and then send it to the recipients with attachments if any but after doing this the format get messed. So can you please help me to format the body of the mail content after i put the body content from the saved mails to the new mail body. I am following your code to send mails. So use the same method but provide me solution to format the body of the mail.
Thanks...