Sub SendEM()
If [a1] = "" And [a2] = "" Then
Columns("A:A").Delete
End If
On Error Resume Next
ActiveSheet.Name = "1-20 Email Address"
'SHANDIAO ssc.krexportdocs@cma-cgm.com 无效公邮
For X1 = 2 To Sheets("1-20 Email Address").Range("F65536").End(xlUp).ROW
If Sheets("1-20 Email Address").Cells(X1, "F") = "ssc.krexportdocs@cma-cgm.com" Then
Sheets("1-20 Email Address").Cells(X1, "F").ClearContents
End If
Next X1
For X2 = 2 To Sheets("1-20 Email Address").Range("G65536").End(xlUp).ROW
If Sheets("1-20 Email Address").Cells(X2, "G") = "ssc.krexportdocs@cma-cgm.com" Then
Sheets("1-20 Email Address").Cells(X2, "G").ClearContents
End If
Next X2
Dim dic
Set dic = CreateObject("scripting.dictionary")
For x = 2 To Sheets("1-20 Email Address").Range("a65536").End(xlUp).ROW
dic(Sheets("1-20 Email Address").Cells(x, "a").Value) = dic(Sheets("1-20 Email Address").Cells(x, "a").Value) & Sheets("1-20 Email Address").Cells(x, "f").Value & ";"
Next x
Sheets("1-20 Email Address").Range("h2").Resize(dic.Count) = Application.Transpose(dic.Keys)
Sheets("1-20 Email Address").Range("i2").Resize(dic.Count) = Application.Transpose(dic.Items)
For Y = 2 To Sheets("1-20 Email Address").Range("h65536").End(xlUp).ROW
Sheets("1-20 Email Address").Cells(k + 2, "j") = Sheets("Page1_1").Range("A:A").Find(Sheets("1-20 Email Address").Cells(Y, "h")).Offset(0, 9).Value
Sheets("1-20 Email Address").Cells(k + 2, "k") = Sheets("Page1_1").Range("K:K").Find(Sheets("1-20 Email Address").Cells(Y, "h").Value).Offset(0, 4).Value
k = k + 1
Next Y
Dim outlookapp As Outlook.Application
Dim outlookitem As Outlook.mailitem
Set outlookapp = New Outlook.Application
subjecttext = "Missing CNEE's email address for BL#"
subjecttext1 = " *Arrival-Notice Sending Purpose* ETA:"
subjecttext2 = " DPcode:"
bodytext = "Dear POL Colleague,"
bodytext1 = "Please provide CEE's email address for sending AN, thanks."
bodytext2 = "BL:"
'kaishixunhuan
For i = 2 To Sheets("1-20 Email Address").Range("H65536").End(xlUp).ROW
Set outlookitem = outlookapp.createitem(olmailitem)
BL = Sheets("1-20 Email Address").Cells(i, "H")
ETA = Sheets("1-20 Email Address").Cells(i, "J")
T = Sheets("1-20 Email Address").Cells(i, "I")
DPc = Sheets("1-20 Email Address").Cells(i, "k")
With outlookitem
.Display
.To = T
.CC = "gsc.northchinaimport@cma-cgm.com;bob.fu@apl.com"
.SendUsingAccount = outlookapp.Session.Accounts.Item(2)
.Subject = subjecttext & BL & subjecttext1 & ETA & subjecttext2 & DPc
.HTMLBody = bodytext & "<br/><br/>" & bodytext1 & "<br/><br/>" & bodytext2 & BL & .HTMLBody
End With
Set outlookitem = Nothing
Set Y = Nothing
Next i
Set outlookapp = Nothing
End Sub
Sub AMEmailSend()
Dim i, BL, CN, PC, PN, SD, POL As String
SD = "bob.fu@apl.com"
Dim outlookapp As Outlook.Application
Dim outlookitem As Outlook.mailitem
Set outlookapp = New Outlook.Application
subjecttext = "LARA US-NO EMAIL FOR AN BL:"
bodytext = "APL.Customer.Care,"
bodytext1 = "Please kindly provide email address of "
bodytext2 = " for sending AN & invoice, and also contact customer the AN sent failed due to no email, thanks."
bodytext3 = "BL:"
bodytext4 = "Partner Code:"
bodytext5 = "Contact Name: "
bodytext6 = "POL:"
'kaishixunhuan
For i = 2 To Range("b65536").End(xlUp).ROW
receiver = "APL.Customer.Care;"
Set outlookitem = outlookapp.createitem(olmailitem)
BL = Cells(i, "b")
CN = Cells(i, "i")
PC = Cells(i, "j")
PN = Cells(i, "k")
POL = Cells(i, "d")
With outlookitem
.Display
.To = receiver
.CC = SD
.Subject = subjecttext & BL
.HTMLBody = bodytext & "<br/><br/>" & bodytext1 & CN & bodytext2 & "<br/><br/>" & bodytext3 & BL & "<br/><br/>" & bodytext6 & POL & "<br/><br/>" & bodytext4 & PC & "<br/><br/>" & bodytext5 & PN & .HTMLBody
End With
Set outlookitem = Nothing
Set Y = Nothing
Next i
Set outlookapp = Nothing
End Sub
Sub NoAnNoEmial()
On Error Resume Next
ActiveSheet.Name = "1-20 Email Address"
Dim dic
Set dic = CreateObject("scripting.dictionary")
For x = 2 To Sheets("1-20 Email Address").Range("a65536").End(xlUp).ROW
dic(Sheets("1-20 Email Address").Cells(x, "a").Value) = dic(Sheets("1-20 Email Address").Cells(x, "a").Value) & Sheets("1-20 Email Address").Cells(x, "f").Value & ";"
Next x
Sheets("1-20 Email Address").Range("h2").Resize(dic.Count) = Application.Transpose(dic.Keys)
Sheets("1-20 Email Address").Range("M2").Resize(dic.Count) = Application.Transpose(dic.Items)
For Y = 2 To Sheets("1-20 Email Address").Range("h65536").End(xlUp).ROW
Sheets("1-20 Email Address").Cells(k + 2, "I") = Sheets("Page1_1").Range("B:B").Find(Sheets("1-20 Email Address").Cells(Y, "h")).Offset(0, 4).Value
Sheets("1-20 Email Address").Cells(k + 2, "J") = Sheets("Page1_1").Range("B:B").Find(Sheets("1-20 Email Address").Cells(Y, "h").Value).Offset(0, 6).Value
Sheets("1-20 Email Address").Cells(k + 2, "L") = Date + 3
k = k + 1
Next Y
'查找code
Set conn = CreateObject("adodb.connection")
Set rst = CreateObject("ADODB.recordset")
conn.Open "provider=Microsoft.ACE.OLEDB.12.0;extended properties=excel 12.0;data source=" & "\\Cngscapl-spf302\IB\AM Team\01 IB - LARA\15 Personal Folder\bOB\SHA Email Ask Atuo\DP Code.xlsx"
rst.Open "select * from [Sheet1$]", conn, adOpenKeyset, adLockOptimistic
On Error Resume Next
For z = 2 To Sheets("1-20 Email Address").Range("h65536").End(xlUp).ROW
If Len(Sheets("1-20 Email Address").Cells(z, "I")) > 6 Then
Cells(z, "K") = rst.Fields(Sheets("1-20 Email Address").Cells(z, "J") & Right(Sheets("1-20 Email Address").Cells(z, "I").Value, 2))
Else
Cells(z, "K") = rst.Fields(Sheets("1-20 Email Address").Cells(z, "J") & "MA")
End If
Next z
On Error GoTo 0
Dim outlookapp As Outlook.Application
Dim outlookitem As Outlook.mailitem
Set outlookapp = New Outlook.Application
subjecttext = "Missing CNEE's email address for BL#"
subjecttext1 = " *Arrival-Notice Sending Purpose* ETA:"
subjecttext2 = " DPcode:"
bodytext = "Dear POL Colleague,"
bodytext1 = "Please provide CEE's email address for sending AN, thanks."
bodytext2 = "BL:"
'kaishixunhuan
For i = 2 To Sheets("1-20 Email Address").Range("H65536").End(xlUp).ROW
Set outlookitem = outlookapp.createitem(olmailitem)
BL = Sheets("1-20 Email Address").Cells(i, "H")
ETA = Sheets("1-20 Email Address").Cells(i, "l")
T = Sheets("1-20 Email Address").Cells(i, "M")
DPc = Sheets("1-20 Email Address").Cells(i, "K")
With outlookitem
.Display
.To = T
.CC = "GSC.BFU@cma-cgm.com;gsc.northchinaimport@cma-cgm.com"
.SendUsingAccount = outlookapp.Session.Accounts.Item(2)
.Subject = subjecttext & BL & subjecttext1 & ETA & subjecttext2 & DPc
.HTMLBody = bodytext & "<br/><br/>" & bodytext1 & "<br/><br/>" & bodytext2 & BL & .HTMLBody
End With
Set outlookitem = Nothing
Set Y = Nothing
Next i
Set outlookapp = Nothing
End Sub
Sub email_s()
Call FINDStatus
'SHANDIAO ssc.krexportdocs@cma-cgm.com 无效公邮
For X1 = 2 To Sheets(1).Range("a65536").End(xlUp).ROW
If LCase(Sheets(1).Cells(X1, "g").Value) = "ssc.krexportdocs@cma-cgm.com" Or LCase(Sheets(1).Cells(X1, "g").Value) = "twn.booking@cma-cgm.com" _
Or LCase(Sheets(1).Cells(X1, "g").Value) = "ssc.indexportdocs@cma-cgm.com" Then 'ssc.indexportdocs@cma-cgm.com
Sheets(1).Cells(X1, "g").ClearContents
End If
Next X1
For X2 = 2 To Sheets(1).Range("a65536").End(xlUp).ROW
If LCase(Sheets(1).Cells(X2, "h").Value) = "ssc.krexportdocs@cma-cgm.com" Or LCase(Sheets(1).Cells(X2, "h").Value) = "twn.booking@cma-cgm.com" _
Or LCase(Sheets(1).Cells(X2, "h").Value) = "ssc.indexportdocs@cma-cgm.com" Then
Sheets(1).Cells(X2, "h").ClearContents
End If
Next X2
Dim dic
Set dic = CreateObject("scripting.dictionary")
For x = 2 To Sheets(1).Range("a65536").End(xlUp).ROW
dic(Sheets(1).Cells(x, "a").Value) = dic(Sheets(1).Cells(x, "a").Value) & Sheets(1).Cells(x, "g").Value & ";"
Next x
Sheets(1).Range("I2").Resize(dic.Count) = Application.Transpose(dic.Keys)
Sheets(1).Range("J2").Resize(dic.Count) = Application.Transpose(dic.Items)
Dim outlookapp As Outlook.Application
Dim outlookitem As Outlook.mailitem
Set outlookapp = New Outlook.Application
subjecttext = "Missing CNEE's email address for BL#"
subjecttext1 = " *Arrival-Notice Sending Purpose* ETA:"
subjecttext2 = " DPcode:"
bodytext = "Dear POL Colleague,"
bodytext1 = "Please provide CEE's email address for sending AN, thanks."
bodytext2 = "BL:"
'kaishixunhuan
For i = 2 To Sheets(1).Range("A65536").End(xlUp).ROW
Set outlookitem = outlookapp.createitem(olmailitem)
BL = Sheets(1).Cells(i, "I")
ETA = Sheets(1).Cells(i, "F")
T = Sheets(1).Cells(i, "J")
DPc = Sheets(1).Cells(i, "E")
With outlookitem
.Display
.To = T
.CC = "gsc.northchinaimport@cma-cgm.com;bob.fu@apl.com"
.SendUsingAccount = outlookapp.Session.Accounts.Item(2)
.Subject = subjecttext & BL & subjecttext1 & ETA & subjecttext2 & DPc
.HTMLBody = bodytext & "<br/><br/>" & bodytext1 & "<br/><br/>" & bodytext2 & BL & .HTMLBody
End With
Set outlookitem = Nothing
Set Y = Nothing
Next i
Set outlookapp = Nothing
End Sub