メールに文字列を送信していますが、次のように 1 行に 1 文が必要です。
"Loaded LLARY_AR with 0 features
Loaded LLARY_LN with 44 features
Loaded LLARY_PT with 23 features"
しかし、文字列連結に 1 つの改行を追加すると、次のように 1 つではなく 2 つの改行が得られます。
"Loaded LLARY_AR with 0 features
Loaded LLARY_LN with 44 features
Loaded LLARY_PT with 23 features"
改行を含めないと、次のようになります。
"Loaded LLARY_AR with 0 features Loaded LLARY_LN with 44 features Loaded LLARY_PT with 23 features"
コードは次のとおりです。
msgemail = ""
for fcl in trnlist:
try:
tofc = param["tsde"]+"\\"+param["trema"]+fcl
fromfc = param["msde"]+"\\"+param["mchema"]+fcl
arcpy.DeleteFeatures_management(tofc)
arcpy.Append_management(fromfc, tofc)
msgemail +="\nLoaded "+fcl+" with "+str(arcpy.GetCount_management(fromfc))+" features"
del fcl, tofc, fromfc
except:
msgemail +="\nUnsuccessful!! "+fcl
emailto = ["email@to","email@to"]
server = smtplib.SMTP('server.here')
header = "Results:\n"
subject = "Data"
mailmessage = header+msgemail+"\n\nCheck log for details"
message = 'Subject: %s\n\n%s' %(subject, mailmessage)
for e in emailto:
try:
server.sendmail("email@from",e, message)
except:
arcpy.AddMessage(e+" was not sent an email.")
server.quit()
改行がこのように機能する理由がわかりません..そして初心者..明らかにここに何かが欠けています。
これにより、適切にフォーマットされた電子メールが生成されることがわかりました (ただし、..GetCount..プロセスからの必要な情報は含まれていません)。
msgemail +="\nLoaded"+fcl
これらは適切にフォーマットされた電子メールにはなりませんが、
msgemail +="\nLoaded "+fcl+" with "+str(arcpy.GetCount_management(fromfc))+" features"
msgemail +="\nLoaded "+fromcnt
msgemail +="\nLoaded "+fromcnt+" testing for string at end"