我想实现,根据使用者选择的 部门(Combo1.Text )值,对应单据的内容直接自动发送给对应的部门主管邮箱里,请高手指教,还有.RecipDisplayName = txtSendTo.Text如要发送多人,怎么做?
Private Sub cmdSend_Click() MAPISession1.SignOn
With MAPIMessages1
.MsgIndex = -1
.RecipDisplayName = txtSendTo.Text
.MsgSubject = "物品&车辆管理审核单"
'.MsgNoteText = txtMessage.Text
.MsgNoteText = "S/N : " & Txh_SNO.Text & vbNewLine & _
"N/O : " & txhReg_no.Text & vbNewLine & _
"日期 : " & dtpDate.value & vbNewLine & _
"搬出入 : " & txtBringName.Text & vbNewLine & _
"部门 : " & Combo1.Text & vbNewLine & _
"证件号码 : " & txtCardNumber.Text & vbNewLine & _
"车牌号码 : " & txtCarNumber.Text & vbNewLine & _
"搬出入单位 : " & Texbring_comp.Text & vbNewLine & _
"出入站 : " & cmdStation.Text & vbNewLine & _
"送货类别 : " & cmbArticleStye.Text & vbNewLine & _
"物品名 : " & Texhpart_name.Text & vbNewLine & _
"搬出时间 : " & DTPicker1(1).value & DTPicker2(1) & vbNewLine & _
"返还时间 : " & DTPicker1(0).value & DTPicker2(0) & vbNewLine & _
"收货人 : " & txtGetName.Text & vbNewLine & _
"分机 : " & txtTel.Text & vbNewLine & _
"保安确认 : " & txtGuard_id.Text & vbNewLine & _
"签核1 : " & Combo2.Text & vbNewLine & _
"签核2 : " & Combo3.Text & vbNewLine & _
"签核3 : " & Combo4.Text
.SessionID = MAPISession1.SessionID
.Send
End With
MAPISession1.SignOff
MsgBox "邮件发送完毕!", , "发送邮件"
End Sub
Private Sub cmdSend_Click() MAPISession1.SignOn
With MAPIMessages1
.MsgIndex = -1
.RecipDisplayName = txtSendTo.Text
.MsgSubject = "物品&车辆管理审核单"
'.MsgNoteText = txtMessage.Text
.MsgNoteText = "S/N : " & Txh_SNO.Text & vbNewLine & _
"N/O : " & txhReg_no.Text & vbNewLine & _
"日期 : " & dtpDate.value & vbNewLine & _
"搬出入 : " & txtBringName.Text & vbNewLine & _
"部门 : " & Combo1.Text & vbNewLine & _
"证件号码 : " & txtCardNumber.Text & vbNewLine & _
"车牌号码 : " & txtCarNumber.Text & vbNewLine & _
"搬出入单位 : " & Texbring_comp.Text & vbNewLine & _
"出入站 : " & cmdStation.Text & vbNewLine & _
"送货类别 : " & cmbArticleStye.Text & vbNewLine & _
"物品名 : " & Texhpart_name.Text & vbNewLine & _
"搬出时间 : " & DTPicker1(1).value & DTPicker2(1) & vbNewLine & _
"返还时间 : " & DTPicker1(0).value & DTPicker2(0) & vbNewLine & _
"收货人 : " & txtGetName.Text & vbNewLine & _
"分机 : " & txtTel.Text & vbNewLine & _
"保安确认 : " & txtGuard_id.Text & vbNewLine & _
"签核1 : " & Combo2.Text & vbNewLine & _
"签核2 : " & Combo3.Text & vbNewLine & _
"签核3 : " & Combo4.Text
.SessionID = MAPISession1.SessionID
.Send
End With
MAPISession1.SignOff
MsgBox "邮件发送完毕!", , "发送邮件"
End Sub
case A
case CEnd Select
这个事情没有想象的那么复杂。1 为了便于更新,编写一个如 depart_boss.txt 文件,格式如:市场部,张三@someplace.com
人事部,李四@someplace.com
......2 把文件中的部门读入 ComboBox,主管放入公用数组
Public strBosses() As StringPrivate Sub Form_Load()
Dim strTmp As String, strItems() As String
Open App.Path & "\depart_boss.txt" For Input As #1
Redim strBosses(LOF(1)\2) '先将数组开大一些Do Until EOF(1)
Line Input #1, strTmp
strItems = Split(strTmp)
If Ubound(strItem) Then
Combo1.AddItem strItems(0)
strBosses(Combo1.NewListIndex) = strItems(1)
End If
LoopReDim Preserve strBosses(Combo1.ListCount - 1)
End Sub发送时,
.RecipDisplayName = strBosses(Combo1.ListIndex)发送多人,最好用可多选的 ListBox。用一段代码将所选部门对应收件人用分号连接成串即可。