hungvuong1009
Thành viên mới

- Tham gia
- 12/3/12
- Bài viết
- 1
- Được thích
- 0
Chào mọi người.
Mình tham khảo được một đoạn Code để hạn chế việc quên gửi file đính kèm khi gửi Email có file đính kèm.
Đoạn code như sau:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim retMB As Variant
Dim strBody As String
Dim iIndex As Long
On Error GoTo handleError
iIndex = InStr(Item.Body, "file")
If iIndex > 0 And Item.Attachments.Count = 0 Then
retMB = MsgBox("You may have forgotten to attach a file." & vbCrLf & vbCrLf & "Do you still want to continue?", vbQuestion + vbYesNo + vbMsgBoxSetForeground)
If retMB = vbNo Then Cancel = True
End If
handleError:
If Err.Number <> 0 Then
MsgBox "Outlook Attachment Alert Error: " & Err.Description, vbExclamation, "Outlook Attachment Alertr Error"
End If
End Sub
Với đoạn code trên, mình mới chỉ kiểm tra được trong nội dung Email có từ "file", mình muốn thêm các từ khác nữa như là "attach", "attached",... thì phải làm thế nào.
Mong các bạn giúp đỡ. Cảm ơn mọi người.
Mình tham khảo được một đoạn Code để hạn chế việc quên gửi file đính kèm khi gửi Email có file đính kèm.
Đoạn code như sau:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim retMB As Variant
Dim strBody As String
Dim iIndex As Long
On Error GoTo handleError
iIndex = InStr(Item.Body, "file")
If iIndex > 0 And Item.Attachments.Count = 0 Then
retMB = MsgBox("You may have forgotten to attach a file." & vbCrLf & vbCrLf & "Do you still want to continue?", vbQuestion + vbYesNo + vbMsgBoxSetForeground)
If retMB = vbNo Then Cancel = True
End If
handleError:
If Err.Number <> 0 Then
MsgBox "Outlook Attachment Alert Error: " & Err.Description, vbExclamation, "Outlook Attachment Alertr Error"
End If
End Sub
Với đoạn code trên, mình mới chỉ kiểm tra được trong nội dung Email có từ "file", mình muốn thêm các từ khác nữa như là "attach", "attached",... thì phải làm thế nào.
Mong các bạn giúp đỡ. Cảm ơn mọi người.