Jeg kan ikke helt se hvordan jeg skal anvende disse?
For en god ordens skyld bringer jeg her hele min mailprocedure:
Public Sub SendMail()
Dim Bund
Dim MitRange As Variant
Dim iMsg As Object
Dim iConf As Object
Dim WB2 As Workbook
Dim WBname As String
Dim Flds As Variant
Dim BUTIK As String
Sheets("Mail").Activate
Bund = Cells(65536, 1).End(xlUp).Row
MitRange = Range("A1:C" & Bund)
Application.ScreenUpdating = False
WB1Navn = ActiveWorkbook.Name
a = 2
b = 3
For I = 1 To Bund
Select Case MitRange(I, 3)
Case 1
a = a + 2
b = b + 2
Sheets(Array(1, 2, 3, a, b, "Forside")).Copy
BUTIK = MitRange(I, 1)
GoSub Fortsaet:
Case 2
'HER STARTER UDFORDRINGEN!
'ANTAL VARIABLER I MIN ARRAY KAN VÆRE FORSKELLIG FRA GANG TIL GANG
'-----------------------------------------------------------------
'NOGLE GANG VIL MIN ARRAY F.EKS. SE SÅDAN UD:
Sheets(Array(1, 2, 3, 4, "Forside")).Copy
'NOGLE GANG VIL MIN ARRAY F.EKS. SE SÅDAN UD:
Sheets(Array(1, 2, 3, 4, 5, 6, 7, "Forside")).Copy
'NOGLE GANG VIL MIN ARRAY F.EKS. SE SÅDAN UD:
Sheets(Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, "Forside")).Copy
BUTIK = MitRange(I, 1)
GoSub Fortsaet:
End Select
Next I
GoTo Faerdig:
Fortsaet:
Set WB2 = ActiveWorkbook
' It will save the new file with the ActiveSheet in C:/ with a Date and Time stamp
WBname = WB1Navn & "_" & BUTIK & ".xls"
WB2.SaveAs "C:/" & WBname
WB2.Close False
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.dou.dk"
.Item("
http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = MitRange(I, 2)
.CC = ""
.BCC = ""
.From = """Afsender"" <pd@innoteck.dk>"
.Subject = "Test af maildistribution."
.TextBody = "Fremsendes uden særlig følgeskrivelse."
.AddAttachment "C:/" & WBname
.Send
End With
'If you not want to delete the file you send delete this line
Kill "C:/" & WBname
Set iMsg = Nothing
Set iConf = Nothing
Set WB2 = Nothing
Workbooks(WB1Navn).Activate
Return
Set WB1 = Nothing
Faerdig:
Application.ScreenUpdating = True
End Sub