![]() |
How Email does not need user interaction ?
Hi I am trying to send email with Microsoft Outlook from Excel using VBA
code!! Here is my code and is working Perfect With Application .EnableEvents = False .ScreenUpdating = False End With Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "This is a test!" & vbNewLine & _ "Please ignore it" With OutMail .To = "xxxxxxxxx" .CC = "" .BCC = "" .Subject = "Here is Counters Alarm file date " & datevar & " and time " & hourvar & ".XLS" .Body = strbody .Attachments.Add (dirvar & "Counters_" & datevar & "_" & hourvar & ".xls") 'You can add other files also like this '.Attachments.Add ("C:\test.txt") .send End With With Application .EnableEvents = True .ScreenUpdating = True End With Set OutMail = Nothing Set OutApp = Nothing But my problem is that before sending it it needs a user interaction because the following message appears from the Microsoft Office Outlook "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" " and the user have to select an option Yes or No. But I dont want this I want the default option to be YES. How can I do this via my code ??? Or is there any option in the Microsoft Office Outlook to do it just once ?? Thanks in advance |
How Email does not need user interaction ?
Hi,
This may work for you http://www.rondebruin.nl/cdo.htm Mike "Koulla" wrote: Hi I am trying to send email with Microsoft Outlook from Excel using VBA code!! Here is my code and is working Perfect With Application .EnableEvents = False .ScreenUpdating = False End With Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "This is a test!" & vbNewLine & _ "Please ignore it" With OutMail .To = "xxxxxxxxx" .CC = "" .BCC = "" .Subject = "Here is Counters Alarm file date " & datevar & " and time " & hourvar & ".XLS" .Body = strbody .Attachments.Add (dirvar & "Counters_" & datevar & "_" & hourvar & ".xls") 'You can add other files also like this '.Attachments.Add ("C:\test.txt") .send End With With Application .EnableEvents = True .ScreenUpdating = True End With Set OutMail = Nothing Set OutApp = Nothing But my problem is that before sending it it needs a user interaction because the following message appears from the Microsoft Office Outlook "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" " and the user have to select an option Yes or No. But I dont want this I want the default option to be YES. How can I do this via my code ??? Or is there any option in the Microsoft Office Outlook to do it just once ?? Thanks in advance |
How Email does not need user interaction ?
Hi I just try it but the following error appers
Send using configuration value is invalid Any help here ?? Thanks "Mike H" wrote: Hi, This may work for you http://www.rondebruin.nl/cdo.htm Mike "Koulla" wrote: Hi I am trying to send email with Microsoft Outlook from Excel using VBA code!! Here is my code and is working Perfect With Application .EnableEvents = False .ScreenUpdating = False End With Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "This is a test!" & vbNewLine & _ "Please ignore it" With OutMail .To = "xxxxxxxxx" .CC = "" .BCC = "" .Subject = "Here is Counters Alarm file date " & datevar & " and time " & hourvar & ".XLS" .Body = strbody .Attachments.Add (dirvar & "Counters_" & datevar & "_" & hourvar & ".xls") 'You can add other files also like this '.Attachments.Add ("C:\test.txt") .send End With With Application .EnableEvents = True .ScreenUpdating = True End With Set OutMail = Nothing Set OutApp = Nothing But my problem is that before sending it it needs a user interaction because the following message appears from the Microsoft Office Outlook "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" " and the user have to select an option Yes or No. But I dont want this I want the default option to be YES. How can I do this via my code ??? Or is there any option in the Microsoft Office Outlook to do it just once ?? Thanks in advance |
How Email does not need user interaction ?
I put also the comments and now the error is "Cannot Connect to the Server "
"Koulla" wrote: Hi I just try it but the following error appers Send using configuration value is invalid Any help here ?? Thanks "Mike H" wrote: Hi, This may work for you http://www.rondebruin.nl/cdo.htm Mike "Koulla" wrote: Hi I am trying to send email with Microsoft Outlook from Excel using VBA code!! Here is my code and is working Perfect With Application .EnableEvents = False .ScreenUpdating = False End With Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "This is a test!" & vbNewLine & _ "Please ignore it" With OutMail .To = "xxxxxxxxx" .CC = "" .BCC = "" .Subject = "Here is Counters Alarm file date " & datevar & " and time " & hourvar & ".XLS" .Body = strbody .Attachments.Add (dirvar & "Counters_" & datevar & "_" & hourvar & ".xls") 'You can add other files also like this '.Attachments.Add ("C:\test.txt") .send End With With Application .EnableEvents = True .ScreenUpdating = True End With Set OutMail = Nothing Set OutApp = Nothing But my problem is that before sending it it needs a user interaction because the following message appears from the Microsoft Office Outlook "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" " and the user have to select an option Yes or No. But I dont want this I want the default option to be YES. How can I do this via my code ??? Or is there any option in the Microsoft Office Outlook to do it just once ?? Thanks in advance |
How Email does not need user interaction ?
Be sure the SMTP server is correct
-- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Koulla" wrote in message ... I put also the comments and now the error is "Cannot Connect to the Server " "Koulla" wrote: Hi I just try it but the following error appers Send using configuration value is invalid Any help here ?? Thanks "Mike H" wrote: Hi, This may work for you http://www.rondebruin.nl/cdo.htm Mike "Koulla" wrote: Hi I am trying to send email with Microsoft Outlook from Excel using VBA code!! Here is my code and is working Perfect With Application .EnableEvents = False .ScreenUpdating = False End With Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "This is a test!" & vbNewLine & _ "Please ignore it" With OutMail .To = "xxxxxxxxx" .CC = "" .BCC = "" .Subject = "Here is Counters Alarm file date " & datevar & " and time " & hourvar & ".XLS" .Body = strbody .Attachments.Add (dirvar & "Counters_" & datevar & "_" & hourvar & ".xls") 'You can add other files also like this '.Attachments.Add ("C:\test.txt") .send End With With Application .EnableEvents = True .ScreenUpdating = True End With Set OutMail = Nothing Set OutApp = Nothing But my problem is that before sending it it needs a user interaction because the following message appears from the Microsoft Office Outlook "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" " and the user have to select an option Yes or No. But I dont want this I want the default option to be YES. How can I do this via my code ??? Or is there any option in the Microsoft Office Outlook to do it just once ?? Thanks in advance |
All times are GMT +1. The time now is 12:29 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com