Is there a simple way to email?

  • Thread starter Thread starter jimmy84c
  • Start date Start date
J

jimmy84c

Hi all,

Just hit a brick wall trying to learn vb.net... I need a simple way to
send an email with attachments. In VBA for MS Access, SendObject worked
perfectly. Is there an equivalent?

I can't use direct SMTP because I can't predict how each client's email
system will be set up (e.g. some using exchange, lotus notes, etc etc).

And I can't use anything specific to one email client, incase they
change clients from lotus to outlook - then I would have to reprogram
etc etc..

Is there any simple way just like SendObject???

Thanks for your time..
 
Hi all,

Just hit a brick wall trying to learn vb.net... I need a simple way to
send an email with attachments. In VBA for MS Access, SendObject worked
perfectly. Is there an equivalent?

I can't use direct SMTP because I can't predict how each client's email
system will be set up (e.g. some using exchange, lotus notes, etc etc).

And I can't use anything specific to one email client, incase they
change clients from lotus to outlook - then I would have to reprogram
etc etc..

Is there any simple way just like SendObject???

Thanks for your time..

In J# (VB should be very similar) :-

import System.Net.Mail.*;

private void btnSend_Click(Object sender, System.EventArgs e)
{
MailAddress myTo = new MailAddress(toaddress);
MailAddress myFrom = new MailAddress(fromaddress);
MailMessage myMessage = new MailMessage(myFrom, myTo);
myMessage.set_Body("This is the body");
myMessage.set_Subject("This is the subject");
SmtpClient myClient = new SmtpClient("smtp.server.net");
myClient.Send(myMessage);
}
 
Thanks for such a fast response! But I don't want to use SMTP for
countless reasons - just want to launch the default email program on
the system, and create a new message (with attachments), which pops up
ready for the user to click "Send".

Just like using "mailto:" - but the problem is that mailto doesn't
support attachments :(
 
AFAIK the only way to do this by using the MAPI ActiveX objects. This is
exactly what they were made for.
http://activex.microsoft.com/controls/vb6/MSMAPI32.CAB
If the user's mail program respects the MAPI API, it'll do what you want.
Both Outlook and Outlook Express both work fine... as does AOL Mail from
what I remember. Not sure about the new guys like Thunderbird. It's easy to
experiment.
 
Jimmy,

No there is no simple way, the only alternative for SMTP is maybe (I never
tried it or saw it in VBNet) is the way as Carlos (CMM) shows.

The attachment is not a standard option from the standard mailclient.

If it is inside an organisation which uses Office Outlook than interop can
be the alternative, as well not the simple way.

Does not help however at least to search to deep.

Cor
 
When you decide to use Outlook then you can expect to have some trouble
sending mail because of Microsofts security policy. Search for
'redemption' to find out how to be able to do your mailstuff without
the annoying blocking.
 
That's true. FYI: even the MAPI ActiveX objects trigger Outlook's Object
Model Guard (at least in Outlook 2003).... which is annoying!
 
Back
Top