473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

doubt sending emails from Visual. net 2010

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 1343
tlhintoq
3,525 Expert 2GB
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 Expert Mod 8TB
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
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...
2
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 -...
0
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...
3
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...
3
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...
2
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...
7
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. ...
2
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.