Outlook VBA-如何在转发,回复或重播所有邮件之前在邮件主题上添加后缀?

时间:2018-12-19 09:28:32

标签: vba outlook outlook-vba

我需要转发或回复邮件,然后在主题上添加后缀,然后发送。 预先感谢

2 个答案:

答案 0 :(得分:0)

您可以replyreplyAl发送电子邮件,并使用以下代码为主题添加后缀:

#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <aio.h>
#include <string.h>
#include <fcntl.h> // open -> file descriptor O_RDONLY, O_WRONLY, O_RDWR
#include <errno.h>
#include <unistd.h>

typedef struct thread_args {
    char *source_path;
    char *destination_path;
    long int buffer_size;
    long int buffer_size_last; // buffer size for the last thread in case there is a remainder.
    long int offset;
    int priority;
} t_args;


void *worker(void *thread_args) {


    t_args *arguments = (t_args *) thread_args;


    struct aiocb *aiocbRead;

    aiocbRead = calloc(1, sizeof(struct aiocb));

    aiocbRead->aio_fildes = open(arguments->source_path, O_RDONLY);

    if (aiocbRead->aio_fildes == -1) {
        printf("Error");

    }

    printf("opened on descriptor %d\n", aiocbRead->aio_fildes);

    aiocbRead->aio_buf = malloc(sizeof(arguments->buffer_size));
    aiocbRead->aio_offset = arguments->offset;
    aiocbRead->aio_nbytes = (size_t) arguments->buffer_size;
    aiocbRead->aio_reqprio = arguments->priority;

    int s = aio_read(aiocbRead);

    if (s == -1) {
        printf("There was an error");
    }

    while (aio_error(aiocbRead) == EINPROGRESS) {}

    printf("Bytes read %ld", aio_return(aiocbRead));

    close(aiocbRead->aio_fildes);

    for (int i = 0; i < arguments->buffer_size ; ++i) {
        printf("%c\n", (*((char *) aiocbRead->aio_buf + i)));
    }
}

// Returns a random alphabetic character
char getrandomChar() {


    int letterTypeFlag = (rand() % 2);

    if (letterTypeFlag)
        return (char) ('a' + (rand() % 26));
    else
        return (char) ('A' + (rand() % 26));
}

void createRandomFile(char *source, int numberofBytes) {

    FILE *fp = fopen(source, "w");

    for (int i = 0; i < numberofBytes; i++) {
        fprintf(fp, "%c", getrandomChar());
    }

    fclose(fp);

}

int main(int argc, char *argv[]) {

    char *source_path = argv[1];
    char *destination_path = argv[2];
    long int nthreads = strtol(argv[3], NULL, 10);


    // Set the seed.
    srand(time(NULL));

    // Get random number of bytes to write to create the random file.
    int numberofBytes = 10 + (rand() % 100000001);

    // Create a random filled file at the source path.
    createRandomFile(source_path, 100);

    // Calculate the payload for each thread.
    long int payload = 100 / nthreads;
    long int payloadLast = payload + 100 % nthreads;

    // Create a thread argument to pass to pthread.
    t_args *thread_arguments = (t_args *) malloc(nthreads * sizeof(t_args));

    for (int l = 0; l < nthreads; ++l) {

        // Set arguments in the struct.
        (&thread_arguments)[l]->source_path = source_path;
        (&thread_arguments)[l]->destination_path = destination_path;
        (&thread_arguments)[l]->buffer_size = payload;
        (&thread_arguments)[l]->buffer_size_last = payloadLast;
        (&thread_arguments)[l]->offset = l * payload;
        (&thread_arguments)[l]->priority = l;

    }


    pthread_t tID[nthreads];

    // Create pthreads.
    for (int i = 0; i < nthreads; ++i) {
        pthread_create(&tID[i], NULL, worker, (void *) &thread_arguments[i]);
    }

    // Wait for pthreads to be done.
    for (int j = 0; j < nthreads; ++j) {
        pthread_join(tID[j], NULL);
    }

    free(thread_arguments);

    return 0;
}

引用来自:

Outlook Reply or ReplyAll to an Email

如果您要转发电子邮件并为主题添加后缀,请参考以下代码:

Option Explicit
Sub ReplyMSG()
    Dim olItem As Outlook.MailItem
    Dim olReply As MailItem ' Reply
    Dim olRecip As Recipient ' Add Recipient

    For Each olItem In Application.ActiveExplorer.Selection
Set olReply = olItem.ReplyAll
olReplay.Subject = = olItem.Subject & “suffix”
    Set olRecip = olReply.Recipients.Add("Email Address Here") ' Recipient Address
        olRecip.Type = olCC
            olReply.HTMLBody = "Hello, Thank you. " & vbCrLf & olReply.HTMLBody
        olReply.Display

        'olReply.Send
    Next olItem
End Sub

引用来自:

Forward Email with its attachment in Outlook 2010

答案 1 :(得分:0)

适当地会很困难,因为根据您的层次结构位置,您将仅具有一定数量的权限,而且我不认为VB Macro将被允许,我在丹麦的许多组织中都知道VB Macros是不行。< / p>

但是您可以在后台创建一个宏,在其中grep当前邮件,然后更改主题,然后将其设置为当您按CTRL + R时,就像通常在回复时一样,但是可能会发生冲突,因此请小心,因为不想在所有电子邮件中使用它。您回复的邮件。