macro updateddfsdfsdfsdf

Download Macro Updateddfsdfsdfsdf

If you can't read please download the document

Upload: jennifer-morgan

Post on 08-Nov-2015

214 views

Category:

Documents


1 download

DESCRIPTION

fsdfsdfsdf

TRANSCRIPT

Function UNameWindows() As String UNameWindows = Environ("USERNAME")End FunctionPrivate Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim oMail As Outlook.MailItem Dim sSubject As String Dim StrName As Variant Dim a As String Dim z As Variant Dim m As Variant Dim Clientlist(0 To 8) As String Dim foundclient As String foundclient = False Clientlist(0) = "gettyimages.com" On Error GoTo Lastline Set oMail = Application.ActiveInspector.CurrentItem Set Mail_Object = CreateObject("Outlook.Application") Dim recips As Outlook.Recipients Dim recip As Outlook.Recipient Dim pa As Outlook.PropertyAccessor Dim emailcount As Integer emailcount = 0 Const PR_SMTP_ADDRESS As String = _ "http://schemas.microsoft.com/mapi/proptag/0x39FE001E" Set recips = oMail.Recipients For Each recip In recips Set pa = recip.PropertyAccessor z = pa.GetProperty(PR_SMTP_ADDRESS) emailcount = emailcount + 1m = m & " " & z NextFor i = LBound(Clientlist) To UBound(Clientlist)If InStr(1, m, Clientlist(i)) > 1 Thenfoundclient = TruePrompt$ = "Mail is being sent to the Client. Do you still want to send the mail?" If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Do you still want to send the mail?") = vbNo Then Cancel = True End If End IfNext If foundclient = False And InStr(1, m, "eclerx.com") = 0 ThenPrompt$ = "Mail is being sent outside eclerx domain. Do you still want to send the mail?" If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Do you still want to send the mail?") = vbNo Then Cancel = True Else Email_Subject = "Mail sent outside eClerx" & SubjectEmail_Send_From = ""'Email_Send_To = "[email protected]" '& ";Email_Cc = ""Email_Bcc = ""Email_Body = UNameWindows & " has sent an email outside eClerx to following recipients " & mOn Error GoTo debugsSet Mail_Object = CreateObject("Outlook.Application")Set Mail_Single = Mail_Object.CreateItem(0)With Mail_Single.Subject = Email_Subject.To = Email_Send_To.CC = Email_Cc.BCC = Email_Bcc.Body = Email_Body.SendEnd Withdebugs: End If 'a = oMail.Recipients ' End If sSubject = oMail.Subject Dim strSubject As String Dim lngres As Long strSubject = Item.Subject' strSubject1 = oMail.Recipients.names oMail.BodyFormat = olFormatHTML 'MsgBox InStr(1, UCase(Item.Body), ".JPG") If Trim(strSubject) = "" Then Prompt$ = "Subject line is blank. Are you sure you want to send the Mail?" If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject line") = vbNo Then Cancel = True End If End If If InStr(1, UCase(Item.Body), ".PNG") 0 Or InStr(1, UCase(Item.Body), ".JPG") 0 Or InStr(1, UCase(Item.Body), ".BMP") 0 Then If Item.Attachments.Count = 1 Then lngres = MsgBox("'Attach' in body, but no attachment - send anyway?", _ vbYesNo + vbDefaultButton2 + vbQuestion, "You asked me to warn you...") If lngres = vbNo Then Cancel = True End If End If If Item.Attachments.Count = 0 And InStr(1, UCase(Item.Body), "ATTACH") 0 Then lngres = MsgBox("'Attach' in body, but no attachment - send anyway?", _ vbYesNo + vbDefaultButton2 + vbQuestion, "You asked me to warn you...") If lngres = vbNo Then Cancel = True End If End IfIf Item.Attachments.Count = 0 And InStr(1, UCase(Item.Body), "PFA") 0 Then lngres = MsgBox("'Attach' in body, but no attachment - send anyway?", _ vbYesNo + vbDefaultButton2 + vbQuestion, "You asked me to warn you...") If lngres = vbNo Then Cancel = True End If End IfLastline:End Sub