Hi,
I know almost nothing about VBA... all the macros i do, i use the record macro function in excel and i am having trouble creating a macro to send the entire workbook to a specific email, that is located in Cell D1.
The email mus have as subject: "Serviço de atendimento ao Público" and as body "Segue o formulário de atendimento ao público preenchido, qualquer dúvida favor entrar em contato"
I found the following macro in the internet,
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub SendEMail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Dim r As Integer, x As Double
For r = 1 To 1 'data in rows 2-4
' Get the email address
Email = Cells(r, 4)
' Message subject
Subj = "Serviço de Atendimento ao Público"
' Compose the messagef
Msg = Msg & "Segue Formulário de Atendimento ao público preenchido" & vbCrLf
Msg = Msg & "Qualquer dúvida, favor entrar em contato"
' Replace spaces with %20 (hex)
Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")
' Replace carriage returns with %0D%0A (hex)
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")
' Create the URL
URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg
' Execute the URL (start the email client)
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
' Wait two seconds before sending keystrokes
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys "%s"
Next r
End Sub
But this macro does not attach the workbook to the email.... I tried solving it by myself, but as said, i know almost nothing on VBA...
Could anyone help me?
Thanks!
I know almost nothing about VBA... all the macros i do, i use the record macro function in excel and i am having trouble creating a macro to send the entire workbook to a specific email, that is located in Cell D1.
The email mus have as subject: "Serviço de atendimento ao Público" and as body "Segue o formulário de atendimento ao público preenchido, qualquer dúvida favor entrar em contato"
I found the following macro in the internet,
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub SendEMail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Dim r As Integer, x As Double
For r = 1 To 1 'data in rows 2-4
' Get the email address
Email = Cells(r, 4)
' Message subject
Subj = "Serviço de Atendimento ao Público"
' Compose the messagef
Msg = Msg & "Segue Formulário de Atendimento ao público preenchido" & vbCrLf
Msg = Msg & "Qualquer dúvida, favor entrar em contato"
' Replace spaces with %20 (hex)
Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")
' Replace carriage returns with %0D%0A (hex)
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")
' Create the URL
URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg
' Execute the URL (start the email client)
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
' Wait two seconds before sending keystrokes
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys "%s"
Next r
End Sub
But this macro does not attach the workbook to the email.... I tried solving it by myself, but as said, i know almost nothing on VBA...
Could anyone help me?
Thanks!