473,666 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

doubt sending emails from Visual. net 2010

1 New Member
I have a management program with which a file sent by mail, the party of running the outlook is great, but when teams do not have outlook express and have only broken and that I have to check if there is me outlook mapi and only use, but that does not go.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Enviar_mail()
  2.   'comprobar si esta outlook o outlook express
  3.   Dim fallo As Boolean = False
  4.  
  5.   Dim Objeto As Object
  6.   ' Crea una referencia al objeto
  7.   Try
  8.     Objeto = CreateObject("Outlook.Application")
  9.   Catch ex As OleDbException
  10.     fallo = True
  11.   End Try
  12.  
  13.   ' No dío error
  14.   If fallo = True Then
  15.     Dim fila As DataRowView
  16.     Dim STRCod As String
  17.  
  18.     For Each fila In Me.List_Proyecto.SelectedItems
  19.       STRCod = fila.Item(2)
  20.       AxMAPIMessages1.AttachmentName = STRCod
  21.       AxMAPIMessages1.AttachmentPathName = ruta & "Archivos\" & Me.ComboCliente.Text & "\" & STRCod
  22.     Next
  23.  
  24.     'lo mandamos con outlook express
  25.     AxMAPISession1.SignOn()
  26.     With AxMAPIMessages1
  27.       WithMAPIMessages()
  28.       .MsgIndex = -1
  29.       .RecipDisplayName = ""
  30.       .MsgSubject = ""
  31.       .MsgNoteText = ""
  32.       .SessionID = AxMAPISession1.SessionID 'MAPISession.SessionID
  33.       .ResolveName()
  34.       .AttachmentIndex = 0
  35.       .AttachmentPosition = 0
  36.       .AttachmentType = 0
  37.       '.Send()
  38.     End With
  39.     AxMAPISession1.SignOff()
  40.  
  41.   Else
  42.     'Crear una aplicación Outlook.
  43.     Dim oApp As Microsoft.Office.Interop.Outlook.Application
  44.     oApp = New Microsoft.Office.Interop.Outlook.Application()
  45.  
  46.     ' Crear un nuevo elemento de correo.
  47.     Dim oMsg As Microsoft.Office.Interop.Outlook._MailItem
  48.     oMsg = oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
  49.     oMsg.Body = "" & vbCr & vbCr
  50.  
  51.     Dim fila As DataRowView
  52.     Dim STRCod As String
  53.  
  54.     Dim sBodyLen As String = oMsg.Body.Length
  55.     Dim oAttachs As Microsoft.Office.Interop.Outlook.Attachments = oMsg.Attachments
  56.     Dim oAttach As Microsoft.Office.Interop.Outlook.Attachment
  57.  
  58.     For Each fila In Me.List_Proyecto.SelectedItems
  59.       STRCod = fila.Item(2)
  60.       oAttach = oAttachs.Add(ruta & "Archivos\" & Me.ComboCliente.Text & "\" & STRCod, , sBodyLen + 1, )
  61.  
  62.       '' Abrir mensaje nuevo
  63.       oMsg.Display()
  64.  
  65.     End If
  66.  
  67. End Sub
May 20 '10 #1
2 1350
tlhintoq
3,525 Recognized Expert Specialist
I wouldn't send email through Outlook at all. As you have already found out, not everyone has it.

Just send an email directly through your application.

http://social.msdn.microsoft.com/For...2-b6df87c25cc8
May 20 '10 #2
Frinavale
9,735 Recognized Expert Moderator Expert
On line 58 in the above posted code you have a For Each loop but you do not have an ending "next" to close the loop.

Other than that, I'm not sure how to check if outlook exists on the machine your application is installed on.

I recommend that you avoid using Outlook and use the .NET tools for sending emails. Check out this Quick reference on how to send email using .NET for more information.

-Frinny
May 27 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2221
by: VB Programmer | last post by:
My company has it's own webserver, which is going to host our ASP.NET web application. We want the website to be able to send out emails. 1. What do I need on the server so that it has the abillity to send out emails? It is a Windows 2000 Professional SP3 server. 2. Any examples (code, etc...) on how to send out emails via an ASP.NET webform? Thanks!
2
9225
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends - I see hebrew, it is just sending by myself using *.aspx scripts). In web.config I have the following : <configuration> <system.web>
0
1369
by: Ryan | last post by:
Outlook problem with encoding characters when sending emails in asp.net I'm putting this out here incase someone has the same problem I did.. I had a problem with German characters not showing up when I sent an email. The problem was fixed with the bodyencoding below... I originally thought it was an outlook problem.. objMessage.From = astrEmailFrom objMessage.Subject = astrEmailSubject
3
394
by: Arek | last post by:
Hey, I have a question, what are the possibilities of sending emails using ASP.net. (and VB.net) What I think is that user can send automatic reminder if he check box on the form and submit. Do I need to have SMTP server? Can it be done without using of SMTP, something similar to automation in VB? I tried before for quite a few days to automate generating word documents and finally I gave up, so I would like to know before I start...
3
1585
by: A | last post by:
Hi all! I would like to ask a question on sending emails... I have a web application that requires sending emails using email templates. The templates that I've made are separate HTML files and would require some data based on what the user has entered. Please help!!!
2
2003
by: Jodye Roebuck | last post by:
I have a program that's been automatically generating and sending emails flawlessly. My clients workstation had an automatic Microsoft security update done on it.. and now it's bombing on this line : lobjMessage.SEND(0,0,0) Apparently, the security patch doesn't allow external programs/utilities to SEND Outlook emails. The emails are saved and can be manually sent out later, but this is obviously not how it's intended to be used.
7
9338
by: mlevit | last post by:
Hi, I send out emails through MS Access via SendObject. I would like to know if there is a way of getting rid of the Outlook Security Popup that comes up every time an email is about to be sent. I have tried Advanced Security For Outlook but it does not seem to popup when sending emails, I’ve used it before for synchronization with my mobile, and it seemed to popup then. Any help would be greatly appreciated
2
1671
by: sam | last post by:
Hi, I made asp.net website. I send e-mail via asp.net page to receiver but receiver cannot get email. I use smartertool Server SMTP. Sending and receiving to localhost is working. Sending emails to remote machines is NOT working. Please can someone tell the solution to solve this problem. cheers,
4
1426
Ali Rizwan
by: Ali Rizwan | last post by:
Hello all, I have made a web page, Now i want to add some features like sending emails. I want to use HTML code to send emails. Email text will be retrieved by combining the text of two text boxes. and email address is also retrieved from a textbox. Thanx I have no idea about such stuff this is my first try for HTML. And plz don't suggest me that using blah procedure is good, plz answer to the point.
0
8444
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.