VBA Problem

P

Piotr

Hi, I have code that sends mail with some files, but there is
something wrong becouse always next reciepent recive dedicated
attachement + all atachements send already to previous reciepents ?
What should I do to make my user form active on the excell start.

Private Sub CommandButton1_Click()

Dim iMsg As Object
Dim iConf As Object
Dim WB1 As Workbook
Dim WB2 As Workbook
Dim R_Cenos As String

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "mail.com.pl"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
.Update
End With



With iMsg
Set .Configuration = iConf
.To = "(e-mail address removed)"
.CC = "(e-mail address removed)"
.BCC = ""
.From = """(e-mail address removed)"
.Subject = "Today" & Format(Now, "dd-mm-yy")
.TextBody = "Today"
.AddAttachment "C:/Test.txt"
' You can add any file you want with this line .AddAttachment
"C:/Test.txt"
.Send
End With


With iMsg
Set .Configuration = iConf
.To = "(e-mail address removed)"
.CC = "(e-mail address removed)"
.BCC = ""
.From = """(e-mail address removed)"
.Subject = "Today" & Format(Now, "dd-mm-yy")
.TextBody = "Today"
.AddAttachment "C:/Test.txt"
' You can add any file you want with this line .AddAttachment
"C:/Test.txt"
.Send
End With



Set iMsg = Nothing
Set iConf = Nothing
Set WB1 = Nothing
Set WB2 = Nothing
Application.ScreenUpdating = True


End Sub
 
P

Piotr

Thank You Ron I have tried
Set iMsg = Nothing
before but wasnt enough
Now It works great, it has saved me 30 min today :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

CDO send mail problem 5
Macro email 4
Sending e-mail using CDO 1
URGENT! Please please help me get smtp mail send working.. 3
Email Using CDO - mixed results 7
Emailing workbook from Excel 3
Excel CDO 5
CDOSYS 1

Top