
Crear/Adjutar archivo correo
Publicado por Claudia (1 intervención) el 24/01/2018 02:38:52
Buen día, espero puedan ayudarme, quiero crear un proceso que me genere un archivo de Excel 2017 con info de un SP de Sql Server 2008 y una vez creado se mande por correo. El código de envió de correo ya lo tengo pero no se como generar y adjuntar un archivo alguna ayuda que me pudieran ofrecer.
El proceso lo cree en Visual Studio 2015
Adjunto código:
El proceso lo cree en Visual Studio 2015
Adjunto código:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Mail;
using System.Net;
using Domino;
namespace EnviarCorreo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
NotesSession _notessession = new NotesSession();
NotesDatabase _notesdatabase = null;
NotesDocument _notesdocument = null;
string sServerName = @"domi05/domi/domie";
string sMailFile = @"mail/clau.nsf";
string password = "micontra";
string sSendTo = @"fulanito@detal.com.mx";
string sSubject = "Prueba";
object oItemValue = null;
_notessession.Initialize(password);
_notesdatabase = _notessession.GetDatabase(sServerName, sMailFile, false);
if (!_notesdatabase.IsOpen)
{
_notesdatabase.Open();
}
_notesdocument = _notesdatabase.CreateDocument();
_notesdocument.ReplaceItemValue("Form", "Memo");
_notesdocument.ReplaceItemValue("SendTo", sSendTo);
_notesdocument.ReplaceItemValue("Subject", sSubject);
NotesRichTextItem _richTextItem = _notesdocument.CreateRichTextItem("Body");
_richTextItem.AppendText("Con copia grupo" + "\r\n");
oItemValue = _notesdocument.GetItemValue(
"SendTo");
_notesdocument.Send(false, ref oItemValue);
//release resources.
_richTextItem = null;
_notesdocument = null;
_notesdatabase = null;
_notessession = null;
MessageBox.Show("El correo fue enviado");
}
}
}
Valora esta pregunta


0