[FONT="]I have a code using CDO.message in VBA to send email from excel through Gmail.[/FONT]
[FONT="]I can successfully send emails and also attach different files. BUT![/FONT]
[FONT="]1. I want to be able see/edit email before sending it! If i am not mistaken ".display" does not work for CDO.message. Any other way to get around that?[/FONT]
[FONT="]2. I can attach saved files. But I want to attach current open file from which I am using macro. I do not necessarily need to save the file after i email it.[/FONT]
[FONT="]Here is my code:[/FONT]
[FONT="]Sub sendemail()
Dim mymail As CDO.message
Set mymail = New CDO.message
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "*********@gmail.com"
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*******"
mymail.Configuration.Fields.Update
With mymail
.Subject = "Test Email from El"
.From = "******@gmail.com"
.To = ""
.CC = ""
.BCC = ""
.TextBody = "Goor morning!"
.AddAttachment "c:\..."
.Send
End With
On Error Resume Next
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, "there was an error"
Exit Sub
End If
MsgBox ("mail has been sent")
Set mymail = Nothing
End Sub
[/FONT]
[FONT="]I can successfully send emails and also attach different files. BUT![/FONT]
[FONT="]1. I want to be able see/edit email before sending it! If i am not mistaken ".display" does not work for CDO.message. Any other way to get around that?[/FONT]
[FONT="]2. I can attach saved files. But I want to attach current open file from which I am using macro. I do not necessarily need to save the file after i email it.[/FONT]
[FONT="]Here is my code:[/FONT]
[FONT="]Sub sendemail()
Dim mymail As CDO.message
Set mymail = New CDO.message
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "*********@gmail.com"
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*******"
mymail.Configuration.Fields.Update
With mymail
.Subject = "Test Email from El"
.From = "******@gmail.com"
.To = ""
.CC = ""
.BCC = ""
.TextBody = "Goor morning!"
.AddAttachment "c:\..."
.Send
End With
On Error Resume Next
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, "there was an error"
Exit Sub
End If
MsgBox ("mail has been sent")
Set mymail = Nothing
End Sub
[/FONT]