Sending attachments using MAPI and outlook security alert message.
-
Hi Friends, i have written code in VB .net for sending mail using MAPI. I am facing two problems. 1. The mail does go, but when i give an attachment, it gives the following exception. System.Runtime.InteropServices.COMException (0x800A7D02): Unspecified Failure has occurred at MSMAPI.MAPIMessagesClass.Send(Object vDialog) at ProcTryMail.tryMail.Pr_SendMail() in D:\Projects\Ems\Backup_Nov17OutSeq\ProcTryMail\tryMail.vb:line 30 MSDN says this occurs when multiple attachments are put. 2. when i finally send mail, i get an outlook warning saying: A program is trying to automatically send e-mail on your behalf. Do you want to allow this? If this is unexpected, it may be a virus and you should choose "No". The code is given below. Public Class tryMail Private objMapiSession As MSMAPI.MAPISession Private objMapiMsgs As MSMAPI.MAPIMessages Private objDebug As EMSDebug.cDebug Public Sub Pr_SendMail() Try objMapiSession = New MSMAPI.MAPISession() objMapiMsgs = New MSMAPI.MAPIMessages() objMapiSession.LogonUI = False objMapiSession.SignOn() objMapiMsgs.SessionID = objMapiSession.SessionID objMapiMsgs.Compose() objMapiMsgs.RecipDisplayName = "-- give a mail id here --" objMapiMsgs.MsgSubject = "From .NET MAPI" objMapiMsgs.AttachmentPathName = "-- give a filepath here --" objMapiMsgs.Send(False) objMapiSession.SignOff() objMapiSession = Nothing objMapiMsgs = Nothing Catch End Try End Sub End Class thanks Alex
-
Hi Friends, i have written code in VB .net for sending mail using MAPI. I am facing two problems. 1. The mail does go, but when i give an attachment, it gives the following exception. System.Runtime.InteropServices.COMException (0x800A7D02): Unspecified Failure has occurred at MSMAPI.MAPIMessagesClass.Send(Object vDialog) at ProcTryMail.tryMail.Pr_SendMail() in D:\Projects\Ems\Backup_Nov17OutSeq\ProcTryMail\tryMail.vb:line 30 MSDN says this occurs when multiple attachments are put. 2. when i finally send mail, i get an outlook warning saying: A program is trying to automatically send e-mail on your behalf. Do you want to allow this? If this is unexpected, it may be a virus and you should choose "No". The code is given below. Public Class tryMail Private objMapiSession As MSMAPI.MAPISession Private objMapiMsgs As MSMAPI.MAPIMessages Private objDebug As EMSDebug.cDebug Public Sub Pr_SendMail() Try objMapiSession = New MSMAPI.MAPISession() objMapiMsgs = New MSMAPI.MAPIMessages() objMapiSession.LogonUI = False objMapiSession.SignOn() objMapiMsgs.SessionID = objMapiSession.SessionID objMapiMsgs.Compose() objMapiMsgs.RecipDisplayName = "-- give a mail id here --" objMapiMsgs.MsgSubject = "From .NET MAPI" objMapiMsgs.AttachmentPathName = "-- give a filepath here --" objMapiMsgs.Send(False) objMapiSession.SignOff() objMapiSession = Nothing objMapiMsgs = Nothing Catch End Try End Sub End Class thanks Alex
The second problem is caused by a security setting in Outlook that Microsoft put in after the outbreak of viruses that emailed themselves to everyone in your Outlook address book. To turn it off, open Outlook (Express) and pick Options from the Tools menu, then click the Security tab, then uncheck "Warn me when applications try to send mail as me." There is no method of getting around this programatically, for obvious reasons... RageInTheMachine9532